title: Android ExpandableListView : set background color of selected item on click
body: <p>I am trying to set a background color for item when the user click on a child item in my <code>expandableListView</code>.</p>
  
  <p>Here is the code :</p>
  
  <pre><code>expListView.setOnChildClickListener(new OnChildClickListener() {
  
  @Override
          public boolean onChildClick(ExpandableListView parent, View v, final int groupPosition, final int childPosition, long id) {
  
              AlertDialog.Builder builder = new AlertDialog.Builder(New_annonce_act_step2.this);
              builder.setMessage("Vous avez choisi la catégorie " +listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition) +", Continuer ?")
              .setPositiveButton("Oui", new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                      Intent myIntent = new Intent(New_annonce_act_step2.this, New_annonce_act_step22.class);
                      myIntent.putExtra("titre", titre);
                      myIntent.putExtra("categorie", categorie);
                      New_annonce_act_step2.this.startActivity(myIntent);
                      finish();
  
                      overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left);
  
                  }
              })
              .setNegativeButton("Non", new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                      // User cancelled the dialog
                  }
              });
              // Create the AlertDialog object and return it
              builder.create();
              builder.show();
  
              return false;
          }
  
      });
  </code></pre>
  
  <p>Here is the ExpandableListView declaration in layout :</p>
  
  <pre><code> &lt;ExpandableListView
              android:id="@+id/nouvelle_annonce_categorie"
              android:layout_width="match_parent"
              android:layout_height="320dp"
              android:layout_marginLeft="1dp"
              android:layout_marginRight="1dp"
              android:choiceMode = "singleChoice"
              android:listSelector = "@drawable/selector_categorie_item"
              android:layout_marginTop="15dp" /&gt;
  </code></pre>
  
  <p>And here is the coe of selector_categorie_item.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"
      android:exitFadeDuration="@android:integer/config_mediumAnimTime"&gt;
  
      &lt;item android:drawable="@android:color/holo_blue_bright" android:state_pressed="true"/&gt;
      &lt;item android:drawable="@android:color/holo_blue_light" android:state_selected="true"/&gt;
      &lt;item android:drawable="@android:color/holo_blue_dark" android:state_activated="true"/&gt;
  
  &lt;/selector&gt;
  </code></pre>