I have an Activity that extends ListActivity where I want items selected in the list to remain highlighted in a chosen colour.
For test purposes I've tried the approach shown below but I can only get items to "flash" the required colour when selected and not stay highlighted. The list is bound to an ArrayAdapter and there is no code concerned with highlighting. The XML layout for each list item is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="top" android:background="@drawable/list_item_background"> <TextView android:id="@+id/list_item" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dip" android:textSize="24sp" /> </LinearLayout> A selector is defined in res/drawable/list_item_background.xml: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:drawable="@color/white"/ > <item android:state_pressed="true" android:drawable="@color/black"/ > <item android:state_selected="true" android:drawable="@color/green"/ > <item android:drawable="@color/red"/> </selector> Colors are given in res/colors.xml: <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <color name="background">#3500FFFF</color> <color name="blue">#ff0000ff</color> <color name="black">#ff000000</color> <color name="green">#ff00ff00</color> <color name="red">#ffff0000</color> <color name="white">#ffffffff</color> </resources> The colours I've chosen are awful but they are only being used for testing at this stage. Can anyone see what's going wrong? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en