title: Changing color of items in ListView - Android
body: <p>I have a ListView and I would like to change the color of the selected item in the list. I can change the color of the selected item below, but how do I revert (or change) the color of all the other items back to their original color?</p>
  
  <pre><code>@Override
      public void onListItemClick(ListView parent, View v, int position, long id) 
          v.setBackgroundColor(Color.CYAN);
      }
  </code></pre>
  
  <p>I tried changing the color of the parent but it doesn't change the color of the items:</p>
  
  <pre><code> @Override
      public void onListItemClick(ListView parent, View v, int position, long id) 
          parent.setBackgroundColor(Color.WHITE);
          v.setBackgroundColor(Color.CYAN);
      }
  </code></pre>
  
  <p>ListView:</p>
  
  <pre><code>        &lt;ListView
          android:id="@id/android:list"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:choiceMode="singleChoice"
          android:clickable="true"
          android:focusable="false"
          android:focusableInTouchMode="false"
          android:drawSelectorOnTop="false" /&gt;
  </code></pre>
  
  <p>Each item is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/contacts_list"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"&gt;
  
  &lt;LinearLayout android:id="@+id/linear"
      android:orientation="horizontal"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:id="@+id/username"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="18sp"
          android:text=""/&gt;
  
      &lt;TextView
          android:id="@+id/lastname"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="18sp"
          android:layout_marginLeft="3sp"
          android:text=""/&gt;
  
      &lt;TextView
          android:id="@+id/firstname"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="18sp"
          android:layout_marginLeft="3sp"
          android:text=""/&gt;
  
      &lt;TextView
          android:id="@+id/sipExt"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textSize="15sp"
          android:textColor="#59696E"
          android:gravity="right"
          android:layout_marginRight="9dp"
          android:textStyle="italic"
          android:text=""/&gt;
  
  &lt;/LinearLayout&gt;
  
      &lt;TextView
      android:id="@+id/alias"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textSize="14sp"
      android:textColor="#a69d86"
      android:textStyle="italic"
      android:layout_below="@id/linear"
      android:text=""/&gt;
  </code></pre>
  
  <p></p>