title: How to change TextView Color Programmatically
body: <p>I am stumped with this seemingly simple task.</p>
  
  <p>I want to simply change the color of a <code>textview</code> and the background color of a <code>linearlayout</code> to colors set in my <code>colors.xml</code> resource file.</p>
  
  <p><strong>I have tried:</strong></p>
  
  <pre><code>myTextView.SetTextColor(this.Resources.GetColor(Resource.Color.myColor));
  </code></pre>
  
  <p>But this is deprecated.</p>
  
  <p><strong>I then tried:</strong></p>
  
  <pre><code>myTextView.SetTextColor(ContextCompat.GetColor(context, Resource.Color.myColor));
  </code></pre>
  
  <p>But <code>ContextCompat.GetColor()</code> returns an <code>int</code> rather than an <code>Android.Graphics.Color</code> so won't compile.</p>
  
  <p><strong>I then tried to instead set the color as part of a <code>style</code>:</strong></p>
  
  <pre><code>  &lt;style name="myColorStyle"&gt;
      &lt;item name="android:textColor"&gt;
        @color/myColor
      &lt;/item&gt;
  ...
    &lt;/style&gt;
  </code></pre>
  
  <p>and set it  first using</p>
  
  <pre><code>myTextView.SetTextAppearance(this, Resource.Style.myColorStyle);
  </code></pre>
  
  <p>but this is also deprecated so</p>
  
  <p><strong>I tried this:</strong> </p>
  
  <pre><code>myTextView.SetTextAppearance(Resource.Style.myColorStyle);
  </code></pre>
  
  <p>but this throws an exception:</p>
  
  <blockquote>
    <p>Java.Lang.NoSuchMethodError: no non-static method "Landroid/widget/TextView;.setTextAppearance(I)V"</p>
  </blockquote>
  
  <p>How is this simple task achieved?</p>
  
  <p>I am coding in <strong>C# using Xamarin</strong> and Visual Studio.</p>