I am trying to programmatically set a custom background color in my ListView Adapter but I want to keep the default Listview Selector style from Android.
I am setting the background color using the "SetBacgroundResource" method of my item view.
I am using Android 4.0 and I tried the example from this blog http://daniel-codes.blogspot.co.nz/2010/07/how-to-change-listview-rows-background.html but using this example the selector shows however the unselected background color is not showing.
How can I achieve this in Android 4.0 ICS?
EDIT: Here is the Resource I am using for the List Item background drawable.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_selected="true" android:drawable="@android:color/transparent" />
<item android:state_selected="true" android:drawable="@android:color/transparent" />
<item android:state_pressed="true" android:state_selected="false" android:drawable="@android:color/transparent" />
<item android:state_selected="false" android:drawable="@color/list_item_first" />
</selector>
The code that I am using to set this background drawable is inside the GetView method of my adatapter. The code is:
convertView.setBackgroundResrouce(R.drawable.list_item_dark);