You need to set the activated style for the list line. The trick is that this is only available at API level 11 and above.
One way to do this is to use two separate styles. In res/values-v11/styles.xml
you can:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="activated" parent="android:Theme.Holo"> <item name="android:background">?android:attr/activatedBackgroundIndicator</item> </style> </resources>
While res/values/styles.xml
you will have:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="activated"> </style> </resources>
Then your line layout will use the activated
style, for example:
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_vertical" android:layout_marginLeft="4dip" android:minHeight="?android:attr/listPreferredItemHeight" style="@style/activated" />
Combined with the existing CHOICE_MODE_SINGLE
logic CHOICE_MODE_SINGLE
this will cause your line to be activated after using it.
source share