问题描述:

i want this when have a click in the listview:

http://i.stack.imgur.com/ysSPN.png

but, i need this:

http://i.stack.imgur.com/ggLLC.png

i trying use a state drawble to change de color of listview

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/red_color" android:state_checked="false"/>

<item android:drawable="@android:color/transparent"/>

</selector>

It is this ok.But the stateDrawble to change color of text view don't work

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true" android:color="@android:color/white"/>

<item android:state_selected="true" android:color="@android:color/white"/>

<item android:state_focused="true" android:color="@android:color/white"/>

<item android:state_checked="false" android:color="@android:color/white"/>

<item android:color="#000000" /></selector>

how to make to change the color of textview ?

网友答案:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/drawer_color" />
<item android:state_focused="false" android:color="@android:color/white" />
<item android:state_selected="true" android:color="@color/drawer_color" />

Then set textColor property of Textview an set clickable=true

 <TextView
            android:clickable="true"
            android:textColor="@drawable/text_selector"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/registration"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true" />
相关阅读:
Top