This one is driving me crazy:
I have a ListView where I want to change the child's background when it is selected. The List Items have a default background, but when there is a background on the items, the selected item doesn't change color...
Let me visualize this a bit:
When I set A background color to the ListView's children I get this:
This is the code of a child in the ListView:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/list_selector_normal">
<TextView android:id="@+id/title_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp" />
<TextView android:id="@+id/description_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
But when I Set some selectors to the listView in the main layout
android:listSelector="@drawable/list_selector"
The selected list item does not change color...
But when I remove the background from the list item (line 5 in the first code block) the selectors do work, but my background is gone:
The selectors xml code:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true"
android:drawable="@drawable/list_selector_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/list_selector_focussed" /> <!-- focused -->
<item android:state_hovered="true"
android:drawable="@color/blue" /> <!-- hovered -->
<item android:drawable="@color/blue" /> <!-- default -->
</selector>
Is there a way (there should be) where I can keep my background (first image) and change the color of the selected item (second image)?