I have a listview that when I select an item, it populates a details view. I want to show the item that was selected in the listview by changing it to green. Trouble is, the selected item does not show as green until I've clicked the same item two times. What am I doing wrong on the selected item that keeps it from changing to green until the item is clicked two times? Here is my xml selector file:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Active list item -->
<item android:state_selected="true"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/lv_bg_selected" />
<!-- Inactive list item -->
<item android:state_selected="false"
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/lv_bg_unselected_state" />
<!-- Pressed list item -->
<item android:state_pressed="true"
android:drawable="@drawable/lv_bg_pressed_state" />
</selector>
And onListitemClick:
@Override
public void onListItemClick(ListView l, View v, int position, long id)
{
.
.
.
v.setSelected(true);
.
.
.
}