title: How to set Listview alternate row color and selected item background color
body: <p>I have one list view. I have assigned alternate row colors like below in adapter's getView() method :</p>
  
  <pre><code>if(position % 2 ==1)
  {
  convertView.setBackgroundColor(Color.rgb(231, 249, 255));
  }
  else
  {
  convertView.setBackgroundColor(Color.rgb(195, 240, 255)); 
  }
  </code></pre>
  
  <p>Above code is working fine. Now I want to change the color of the selected list item. For that I have followed the below procedure:</p>
  
  <p>I have created on listSelector xml like below:</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;!-- Selected --&gt; 
    &lt;item 
      android:state_focused="true" 
      android:state_selected="false" 
      android:drawable="@drawable/focused"/&gt; 
  
    &lt;!-- Pressed --&gt;
    &lt;item 
      android:state_selected="true" 
      android:state_focused="false"
      android:drawable="@drawable/selected" /&gt; 
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>and I have assigned the above selector to my list as below:</p>
  
  <pre><code>myList.setSelector(R.drawable.list_selector);
  </code></pre>
  
  <p>But I am not getting selected list item color.</p>
  
  <p>Can anyone please tell me how to set alternate row color and selected list item color to an android list.</p>