title: Get the resource id for the drawable reference used in styled attribute
body: <p>Having this custom view <code>MyView</code> I define some custom attributes:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;declare-styleable name="MyView"&gt;
          &lt;attr name="normalColor" format="color"/&gt;
          &lt;attr name="backgroundBase" format="integer"/&gt;
      &lt;/declare-styleable&gt;   
  &lt;/resources&gt;
  </code></pre>
  
  <p>And assign them as follows in the layout XML:</p>
  
  <pre><code>    &lt;com.example.test.MyView
          android:id="@+id/view1"
          android:text="@string/app_name"
          . . .
          app:backgroundBase="@drawable/logo1"
          app:normalColor="@color/blue"/&gt;
  </code></pre>
  
  <p>At first I thought I can retrieve the custom attribute <code>backgroundBase</code> using:</p>
  
  <pre><code>TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MyView, defStyle, 0);
  int base = a.getInteger(R.styleable.MyView_backgroundBase, R.drawable.blank);
  </code></pre>
  
  <p>Which works only when the attribute is not assigned and the default <code>R.drawable.blank</code> is returned.<br>
  When <code>app:backgroundBase</code> is assigned an exception is thrown <em>"Cannot convert to integer type=0xn"</em> because, even though the custom attribute format declares it as integer, it really references a <code>Drawable</code> and should be retrieved as follows:</p>
  
  <pre><code>Drawable base = a.getDrawable(R.styleable.MyView_backgroundBase);
  if( base == null ) base = BitMapFactory.decodeResource(getResources(), R.drawable.blank);
  </code></pre>
  
  <p>And this works.<br>
  Now my question:<br>
  <strong>I really don't want to get the <code>Drawable</code> from the TypedArray, I want the integer id corresponding to <code>app:backgroundBase</code> (in the example above it would be  <code>R.drawable.logo1</code>). How can I get it?</strong></p>