title: Android refresh StateListDrawable problem
body: <p>I have a strange problem with StateListDrawable or maybe (probably) I'm missing something. I created a test application for it and the same problem occurs. So, this is my StateListDrawable resourse in file test_selection.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_selected="true"&gt;
    &lt;shape android:shape="rectangle" android:background="#ff0000"&gt;
     &lt;corners android:radius="10dp" /&gt;
     &lt;gradient android:startColor="#ff5555"
      android:endColor="#ff5555" android:angle="0" /&gt;
    &lt;/shape&gt;
   &lt;/item&gt;
   &lt;item android:state_selected="false"&gt;
    &lt;shape android:shape="rectangle" android:background="#eeeeee"&gt;
     &lt;corners android:radius="10dp" /&gt;
     &lt;gradient android:startColor="#eeeeee"
      android:endColor="#eeeeee" android:angle="0" /&gt;
    &lt;/shape&gt;
   &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>It's a very simple selector that draw a red color for selected state and a white rect for the unselected one. </p>
  
  <p>My main.xml template is very simple. I simply use a TextView that uses the selection as background.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="fill_parent"
   android:layout_height="fill_parent"&gt;
   &lt;TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="@string/hello"
    android:textSize="30dp" android:id="@+id/test_view_example" android:background="@drawable/test_selection"/&gt;
   &lt;Button android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/refresh"
    android:onClick="updateView" android:text="refresh"&gt;&lt;/Button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>My Activity code is also very simple.</p>
  
  <pre><code>public class TestDrawableStateActivity extends Activity {
  
   private final static int[] SELECTED_STATE = { android.R.attr.state_selected };
   private final static int[] UNSELECTED_STATE = {};
  
   private TextView textView; 
  
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    textView = (TextView) findViewById(R.id.test_view_example);
   }
  
   @Override
   protected void onResume() {
    super.onResume();
    // Carichiamo la Drawable 
    if(textView.getBackground().setState(SELECTED_STATE)){ 
     textView.invalidate();
    }  
   }
  
   public void updateView(View view) {
    if(textView.getBackground().setState(SELECTED_STATE)){
     textView.invalidate();
    };
   }
  }
  </code></pre>
  
  <p>When Activity starts I try to set the state of my Drawable (the StateListDrawable) with the value SELECTED. 
  It seems all very simple.... but the problem is that the state is not shown. If, later, I click a button and execute the method updateView() the state changes.
  Where is my problem? Where am I wrong?</p>
  
  <p>Thankx a lot
  Max</p>