setTextAppearance through code referencing custom attribute
<p>I am using custom attributes to implement theme switching in my application. I have the following attribute defined:</p>

<pre><code>&lt;resources&gt;
    &lt;attr name="TextAppearance_Footer" format="reference"&gt;&lt;/attr&gt;
&lt;/resources&gt;
</code></pre>

<p>I have two themes which define this attribute differently:</p>

<pre><code>&lt;style name="NI_AppTheme.Dark"&gt;
    &lt;item name="TextAppearance_Footer"&gt;@style/Footer&lt;/item&gt;
&lt;/style&gt;
</code></pre>

<p>The <code>@style/Footer</code> is defined as follows:</p>

<pre><code>&lt;style name="Footer" parent="@android:style/TextAppearance.Large"&gt;
    &lt;item name="android:textColor"&gt;#00FF00&lt;/item&gt; // Green
&lt;/style&gt;
</code></pre>

<p>Now if I try to set this style to a <code>TextView</code> using:</p>

<pre><code>textView.setTextAppearance(this, R.attr.TextAppearance_Footer);
</code></pre>

<p>It does not work (i.e. does not set the text to Green). However, if I specify the text appearance via xml using:</p>

<pre><code>android:textAppearance="?TextAppearance_Footer"
</code></pre>

<p>It works fine. What could I be missing? I need to set the attributes because I want to dynamically be able to switch between themes.</p>

<p><strong>Additional Info:</strong></p>

<p>If I use:</p>

<pre><code>textView.setTextAppearance(this, R.style.NI_AppTheme.Dark);
</code></pre>

<p>It seems to work all right.</p>

<p><strong>EDIT: Tested Working Solution (thanks @nininho):</strong></p>

<pre><code>Resources.Theme theme = getTheme();
TypedValue styleID = new TypedValue();
if (theme.resolveAttribute(R.attr.Channel_Title_Style, styleID, true)) {
     channelTitle.setTextAppearance(this, styleID.data);
}
</code></pre>
