title: Pressed android button state
body: <p>I've been following a tutorial that explains how to use background for a button with different states but it doesn't seem to work :S </p>
  
  <p>Here is my 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:drawable="@drawable/boutonn" android:state_window_focused="false"/&gt;
      &lt;item android:drawable="@drawable/boutonnpousse" android:state_pressed="true"/&gt;
      &lt;item android:drawable="@drawable/boutonnpousse" android:state_focused="true"/&gt;
      &lt;item android:drawable="@drawable/boutonn" android:state_focused="false" 
      android:state_pressed="false" /&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>This is an xml code that I've placed in my drawable folder, here is a part of the xml of the activity that uses these buttons :</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/backgrounddd"
      android:orientation="vertical" &gt;
  
              &lt;Button
                  android:id="@+id/bNoteRemind"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:layout_gravity="center"
                  android:background="@drawable/imagebutton1" /&gt; 
      ...
  </code></pre>
  
  <p>And here is the java class :</p>
  
  <pre><code>public class MenuPrincipal extends Activity {
  
      Button NoteRemind;          
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
  
          //on lui associe le layout menuprincipal.xml
          setContentView(R.layout.menuprincipal);
  
          NoteRemind = (Button) findViewById(R.id.bNoteRemind);     
  
          // Si on choisit de rédiger une nouvelle task on va être rediriger sur l'activité NoteReminder
  
          NoteRemind.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                  //On créé l'Intent qui va nous permettre d'afficher l'autre Activity
                  //Mettez le nom de l'Activity dans la quelle vous êtes actuellement pour le premier parametre
                  v.setPressed(true);
  
                  Intent intent = new Intent(MenuPrincipal.this, NoteReminder.class);
                  //Intent intent = new Intent(MenuPrincipal.this, Teste2.class);
                  //On démarre l'autre Activity
                  startActivity(intent);
  
  
              }
          }); ....
  </code></pre>
  
  <p>The button displays well but when I press it it doesn t show the pressed image :s I don't understand what I am doing wrong !</p>
  
  <p>Does anyone see an error somewhere ???</p>
  
  <hr>
  
  <p>Where should I put those lines ? I ve put them in my button xml</p>
  
  <pre><code>    &lt;Button
          android:id="@+id/bNoteRemind"
          android:layout_width="100dp"
          android:layout_height="100dp"
          android:layout_gravity="center"
          android:background="@drawable/imagebutton1"
          android：focusable="true"
          android:focusableInTouchMode="true" /&gt;
  </code></pre>
  
  <p>But now my button background changed to the pressed image without me pressing it :p and it doesn't change</p>