I have a ListFragment whose ListView is set to ListView.CHOICE_MODE_SINGLE. The adapter returns a custom row layout and I'm setting the background of each row layout to a selector.
But I can't seem to define the selector so that on a long-press, the row stays highlighted, but on a normal press, it just highlights briefly.
Here is my selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@color/light_blue" />
<item android:drawable="@android:color/transparent" />
</selector>
The row stays highlighted on long-press, but a normal press also makes the row stay highlighted. I've tried using various combinations of attributes in each item but can't get it right.
Clarification: I would still like it so that when another row is pressed, the previously long-pressed (and highlighted) row becomes un-highlighted. And the above selector does do that.