In my app I retrieve a user's playlist from the server and feel a ListView
with the data. The problem is, that the ListView
does not highlight clicked rows. To prevent rage comments telling me that I don't use search here are things I've tried:
- setting the button in my row to non-focusable
- setting the listSelector both by code and XML (not at the same time)
- trying to change the background of passed
View
in anOnItemClickListener
- using setItemsCanFocus() with bot true and false parameters
- setting an XML drawable with states "selected" and "pressed" to row layout root
Clicks are detected since I tested that using a Toast
. But I just can't force the ListView
to highlight the selected row
ListView
<ListView
android:id="@android:id/list"
android:listSelector="@drawable/list_selected"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/etbg"
android:choiceMode="singleChoice"
android:divider="@color/div" >
</ListView>
Layout used as list row
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/tvListItemArtist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="14dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="Small Text"
android:layout_toRightOf="@+id/tbListPlay"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
<TextView
android:id="@+id/tvListItemSong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tvListItemArtist"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/tvListItemArtist"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
<ImageView
android:id="@+id/img_list_audio_saved"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="50dp"
android:src="@drawable/attention"
android:visibility="gone" />
<Button
android:id="@+id/tbListPlay"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/button_play"
android:focusable="false"
android:focusableInTouchMode="false" />
</RelativeLayout>
Any suggestions?