Keep highlite list item with SimpleCursorAdapter Keep highlite list item with SimpleCursorAdapter sqlite sqlite

Keep highlite list item with SimpleCursorAdapter


You need to set the activated style for your list row. The catch is that this is only available on API Level 11 and higher.

One way to do this is to use two separate styles. In res/values-v11/styles.xml, you could have:

<?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>

Whereas res/values/styles.xml you would have:

<?xml version="1.0" encoding="utf-8"?><resources>  <style name="activated">  </style></resources>

Your row layout would then use that activated style, such as:

<?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 your existing CHOICE_MODE_SINGLE logic, this will leave your row activated after it is tapped.