title: Setting Android TextView text color programmatically with setTextColor() renders android:duplicateParentState invalid
body: <p>I have a listview of simple text items. The TextView in those items looks like this (it's wrapped inside a <code>RelativeLayout</code>):</p>
  
  <pre><code>&lt;TextView
    android:id="@+id/text_language_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:duplicateParentState="true"
    android:textSize="16sp"
    android:textStyle="bold" /&gt;
  </code></pre>
  
  <p>I want to use the following color state selector for the text, which I have called "dark_list_text_states.xml":</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item android:state_pressed="true" android:color="@android:color/white"/&gt;
      &lt;item android:color="@color/dark_list_text"/&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>Normally, of course, I could just set that to the <code>android:textColor</code> property in the xml, but in this case, I need to set one particular item programmatically to a different color, using this selector ("blue_text_states.xml"):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;item android:state_pressed="true" android:color="@android:color/white"/&gt;
      &lt;item android:color="@color/selected_blue"/&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>So I set the text color in the Adapter (<code>language_name</code> and <code>selected</code> are defined earlier in the code):</p>
  
  <pre><code>        TextView text_language_name = (TextView)view.findViewById(R.id.text_language_name);
          if (text_language_name != null) {
              text_language_name.setText(language_name);
              int text_color = selected
                             ? getResources().getColor(R.color.blue_text_states)
                             : getResources().getColor(R.color.dark_list_text_states);
              text_language_name.setTextColor(text_color);
              text_language_name.setDuplicateParentStateEnabled(true);
          }
  </code></pre>
  
  <p>And this works fine, except for one problem: the text color doesn't change when the item is clicked. Even though I call <code>setDuplicateParentStateEnabled(true)</code> on the item right after <code>setTextColor()</code>, that setting is completely ignored.</p>
  
  <p>I have tested this by commenting out the Java code that sets the text color and just setting it in the xml, and the selector works just fine. But if I set textColor programmatically, it is completely incapable of duplicating the parent state.</p>
  
  <p>Has anyone seen this before? Is there a workaround, or is this just an Android bug I have to live with?</p>