Android ListView Item Colour and Scrolling issue
<p>I have a messaging application that displays a list of received messages however I want to highlight the messages that have NOT been read with a colour(Yellow) whereas the other list items remain the default list item colour (White).</p>

<p>I have managed to do this using the code below however whenever I scroll the list then all of the list items regardless of whether they have been read or not will then be the "highlight" colour when they scroll out of view and then back into view.</p>

<p>My list selector:</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:state_selected="true" android:drawable="@android:color/transparent" /&gt;
&lt;item android:state_pressed="true" android:drawable="@android:color/transparent" /&gt;
&lt;item android:state_selected="false" android:drawable="@drawable/messageUnreadColour" /&gt;
</code></pre>

<p></p>

<p>My code behind in my array adapter that applies the setting:</p>

<pre><code>@Override
public View getView(int position, View convertView, ViewGroup parent) {

Message_ListItem entry = items.get(position);  

   ....setup list item etc

   // Get whether the message has been read
   if (!entry.getHasBeenRead()) {

      // Set the colour to highlight the listitem
      convertView.setBackgroundResource(R.drawable.message_listitem_unread);
   }

  return convertView;
}
</code></pre>

<p>I have already removed the cacheColorHint setting on the list to see if this helps, but this has no effect.</p>

<p>Is there any way I can solve this?</p>
