android - Default background on ListView Item -


this 1 driving me crazy:

i have listview want change child's background when selected. list items have default background, when there background on items, selected item doesn't change color...

let me visualize bit:

when set background color listview's children this:

listitems background

this code of child in 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 set selectors listview in main layout

    android:listselector="@drawable/list_selector" 

the selected list item not change color...

but when remove background list item (line 5 in first code block) selectors work, background gone:

listitems without background

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 way (there should be) can keep background (first image) , change color of selected item (second image)?

you can try set normal background in listview xml

    <listview         android:id="@android:id/list"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="@drawable/list_selector_normal"         /> 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -