title: How to retrieve the textColor attribute from a custom style
body: <p>I defined a custom style in <em>styles.xml</em>:</p>
  
  <pre><code>&lt;style name="MyCustomStyle"&gt;
      &lt;item name="android:background"&gt;@drawable/my_background&lt;/item&gt;
      &lt;item name="android:textColor"&gt;@color/my_custom_color&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>and <code>my_custom_color</code> is defined in <em>colors.xml</em>: </p>
  
  <pre><code>&lt;color name="my_custom_color"&gt;#202224&lt;/color&gt;
  </code></pre>
  
  <p>I'm trying to apply those values to a <code>TextView</code> programmatically:</p>
  
  <pre><code>void setStyle(Activity activity, TextView textView, int styleResId) {
      int[] attrs = { android.R.attr.background, android.R.attr.textColor };
      TypedArray style = activity.obtainStyledAttributes(styleResId, attrs);
      textView.setBackground(style.getDrawable(0));
      int color = style.getColor(1, -1);
      textView.setTextColor(color);
      style.recycle();
  }
  </code></pre>
  
  <p>The part that sets the background is working fine but for some reason <code>color</code> is always <code>-1</code> instead of being the color I defined in colors.xml.</p>
  
  <p>What am I doing wrong?</p>