title: Resolving the value of "?android:attr/selectableItemBackground" in code
body: <p><a href="https://stackoverflow.com/questions/7896615/android-how-to-get-value-of-an-attribute-in-code">This answer</a> helped a bit, but doesn't quite cover my issue.</p>
  
  <p>Here is what my XML looks like:</p>
  
  <pre><code>&lt;android.support.v7.widget.CardView
      ... other attributes...
      android:foreground="?android:attr/selectableItemBackground"
      &gt;
  </code></pre>
  
  <p>The issue is that I would like to be able to resolve that attr in code. Here is what I have so far:</p>
  
  <pre><code>val typedValue = TypedValue()
  context.theme.resolveAttribute(R.attr.selectableItemBackground, typedValue, true)
  typedValue.string // "res/drawable/item_background_material.xml"
  typedValue.type   // 3 (string)
  typedValue.data   // 656
  </code></pre>
  
  <p>I could use the linked answer, I suppose, to directly resolve <code>R.drawable.item_background_material</code>, but the whole point of using <code>?android:attr/...</code> is that I don't <em>know</em> where that attr points. How do I make use of the information contained in the <code>TypedValue</code> object to resolve the drawable reference?</p>
  
  <p>Btw, I have tried</p>
  
  <pre><code>val drawableRes = string.substring(string.lastIndexOf("/") + 1, string.indexOf(".xml")) // gross, but it's just a proof of concept
  val drawable = resources.getIdentifier(drawableRes, "drawable", context.packageName)
  </code></pre>
  
  <p>but the result is always <code>0</code>.</p>