title: API21 setButtonTintList on CheckBox
body: <p>I am trying to use the new Android Lollipop API <code>setButtonTintList()</code> to programmatically apply colors to android <code>CheckBox</code>es.</p>
  
  <p>I have set the following basic <code>ColorStateList</code> in <code>checkbox_color.xml</code>:</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_checked="true"
            android:color="@color/red" /&gt;
  
      &lt;item android:state_checked="false"
            android:color="@color/green" /&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>On a specific <code>Button</code> click in my app I inflate a new layout that contains a <code>CheckBox</code> into my main layout (<code>mLayoutTotalItemRow</code>) via:</p>
  
  <pre><code>View itemRow = getActivity().getLayoutInflater().inflate(R.layout.row_add_purchase, mLayoutTotalItemRow, false);
  </code></pre>
  
  <p>After the inflation, I want to apply <code>checkbox_color.xml</code> to the new <code>CheckBox</code> via (the reason I want to do this in code rather than xml is that I want to set different colors depending on some variables):</p>
  
  <pre><code>mCheckBoxEnabled.setButtonTintList(mContext.getResources().getColorStateList(R.color.checkbox_color));
  </code></pre>
  
  <p>Now a strange thing happens, when the <code>CheckBox</code> is first created, it is red (hence <code>state_checked="true"</code>. As soon as I uncheck it, it is green (<code>state_chacked="false"</code>). But when I check it again now, it changes to ticked but it stays green! Hence somehow the internal view state is not changing to "checked".</p>
  
  <p>My checkbox xml:</p>
  
  <pre><code>   &lt;CheckBox
      android:id="@+id/cb_item_enabled"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="@dimen/key_line_1_minus_checkbox_margin"
      android:layout_marginEnd="@dimen/key_line_2_minus_key_line_1_minus_checkbox"
      android:layout_gravity="center_vertical"
      android:checked="true"/&gt;
  </code></pre>
  
  <p>Any ideas what I am doing wrong here?</p>