title: highlighting selected item in custom list view using context menu?
body: <p>I've been trying to set my background colour on this list view and with following multiple tutorials it just doesn't come up, yet no errors are shown.</p>
  
  <p>What I've got is an xml file called colours in the values folder:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;drawable name="red_colour"&gt;#6D0E0E&lt;/drawable&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Which links to an xml in the drawable folder:</p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;item
      android:state_pressed="true"
      android:state_activated="true"
      android:drawable="@drawable/red_colour"&gt;
  &lt;/item&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>I've tried placing the following code android:background:@id"colourhighlight.xml"
  literally everywhere based on various tutorials yet no luck?</p>
  
  <p>Any advice? Please help...</p>
  
  <p>I've got one main class with a context menu:</p>
  
  <pre><code> @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_user_contacts);
  
          // The contacts from the contacts content provider is stored in this cursor
          mMatrixCursor = new MatrixCursor(new String[] { "_id","name","photo","details"} );
  
          // Adapter to set data in the listview
          mAdapter = new SimpleCursorAdapter(getBaseContext(),
                  R.layout.lv_layout,
                  null,
                  new String[] { "name","photo","details"},
                  new int[] { R.id.tv_name,R.id.iv_photo,R.id.tv_details}, 0);
  
          // Getting reference to listview
          final ListView lstContacts = (ListView) findViewById(R.id.lst_contacts);
  
          // Setting the adapter to listview
          lstContacts.setAdapter(mAdapter);
  
          // Creating an AsyncTask object to retrieve and load listview with contacts
          ListViewContactsLoader listViewContactsLoader = new ListViewContactsLoader();
  
          // Starting the AsyncTask process to retrieve and load listview with contacts
          listViewContactsLoader.execute();
  
          //Selecting and highlighting the elements in the listview
          lstContacts.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  view.setActivated(true);
              }
          });
  
          //Creating the context menu and the options for it
          listview = (ListView) findViewById(R.id.lst_contacts);
          listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
          listview.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
              @Override
              public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
                  count = count+1;
                  mode.setTitle(count + " Contacts Selected");
  
  
              }
  
              @Override
              public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  
                  MenuInflater inflater = mode.getMenuInflater();
                  inflater.inflate(R.menu.contact_context_menu, menu);
  
                  return true;
              }
  
              @Override
              public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                  return false;
              }
  
              @Override
              public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                  switch(item.getItemId()){
                      case R.id.delete_id:
                          Toast.makeText(getBaseContext(), count + " Contacts Deselected", Toast.LENGTH_SHORT).show();
                          count = 0;
                          mode.finish();
                          return true;
                          //break;
                      default:
                         return false; //break;
                  }
  
                  //return false;
              }
  
              @Override
              public void onDestroyActionMode(ActionMode mode) {
  
              }
          });
  
      }
  </code></pre>
  
  <p>lv_layout.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent" android:layout_height="match_parent"
     &gt;
  
      &lt;ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/iv_photo"
          android:maxHeight="80dp"
          android:maxWidth="80dp"
          android:adjustViewBounds="true"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:id="@+id/tv_name"
          android:layout_alignParentTop="true"
          android:layout_toRightOf="@+id/iv_photo"
          android:layout_toEndOf="@+id/iv_photo" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall"
          android:id="@+id/tv_details"
          android:layout_below="@+id/tv_name"
          android:layout_toRightOf="@+id/iv_photo"
          android:layout_toEndOf="@+id/iv_photo" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Main layout.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin"
      tools:context="com.example.ankhit.saveme.UserContacts"
      android:background="@drawable/colourhighlight"
      &gt;
  
      &lt;ListView
          android:id="@+id/lst_contacts"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/button"
          /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/instructions"
          android:id="@+id/button"
          android:onClick="showInstructions"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>