So I have a ListView, presenting custom Views (each with an image + text). I want those views to have a different appearance when the user selects them. (with an overlay, but for now I try to make it work with just a background)
If I inflate a row with Android.Resource.Layout.TestListItem, it works, the cell shows the selected state when I click.
However, I try to get a similar effect with my custom layout, and I can't get it to work. Is something missing ?
I have this view layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rowbackground">
... (textview and image)
and rowbackground.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@drawable/bg_a" />
<item android:state_checked="true" android:drawable="@drawable/bg_b" />
<item android:state_pressed="true" android:drawable="@drawable/bg_c" />
<item android:state_selected="false" android:state_checked="false" android:state_pressed="false" android:drawable="@drawable/bg_d"/>
</selector>
But the only two that work are the "default" and the "pressed" states. Not the "selected" one. (I tried also checked, as I see it in some samples)
How can I make my custom-layout View selectable ?