title: Read Newer Theme Attributes On Older Platform
body: <p>I am trying to read attribute values from themes and styles which were designed for platforms that are newer than I am running my application on.</p>
  
  <p><em>Please don't ask why. If you know anything about the libraries I write then you should already know that I like to push the capabilities of the platform :)</em></p>
  
  <p>I am operating under the presumption that when Android styles are compiled the attribute constants are what is used for the keys and therefore should theoretically be able to be read on any platform somehow. This is what I have observed to be happening with layout XMLs in my other libraries with no trouble.</p>
  
  <p>Here is a base test case which shows the problem. This should be compiled using Android 3.0+.</p>
  
  <pre><code>&lt;resources&gt;
      &lt;style name="Theme.BreakMe"&gt;
          &lt;item name="android:actionBarStyle"&gt;@style/Widget.BreakMe&lt;/item&gt;
      &lt;/style&gt;
      &lt;style name="Widget.BreakMe" parent="android:Widget"&gt;
          &lt;item name="android:padding"&gt;20dp&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>The fact that this uses <code>android:actionBarStyle</code> specifically is irreleveant. All that should be understood is that its an attribute which was only available starting with Android 3.0.</p>
  
  <p>Here are the way that I have tried to access these values thus far on platforms <strong>prior to Android 3.0</strong>.</p>
  
  <pre><code>&lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Break Me"
      style="?android:attr/actionBarStyle"
      /&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;declare-styleable name="Whatever"&gt;
      &lt;item name="datStyle" format="reference" /&gt;
  &lt;/declare-styleable&gt;
  
  &lt;style name="Theme.BreakMe.Take2"&gt;
      &lt;item name="datStyle"&gt;?android:attr/actionBarSize&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Break Me"
      style="?attr/datStyle"
      /&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>TypedValue outValue = new TypedValue();
  context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>int[] Theme = new int[] { android.R.attr.actionBarSize };
  int Theme_actionBarSize = 0;
  TypedArray a = context.obtainStyledAttributes(attrs, Theme);
  int ref = a.getResourceId(Theme_actionBarSize, 0);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar, android.R.attr.actionBarStyle, 0);
  </code></pre>
  
  <p>All of them result in this error in LogCat:</p>
  
  <pre><code>E/ResourceType(5618): Style contains key with bad entry: 0x010102ce
  </code></pre>
  
  <p>The <code>0x010102ce</code> constant is the attribute value of <code>android.R.attr.actionBarStyle</code> which seems to indicate the platform is rejecting the attribute before I can even get a chance to access its value.</p>
  
  <p>I am looking for any other way to read attributes like this from the Theme. I'm fairly sure that once I've obtained the style reference I won't have trouble reading its attributes.</p>
  
  <p>Is there any possible way to do this?</p>