Change ListView's text color on click

我们两清 提交于 2019-11-29 11:17:11

Create a new StateListDrawable like you did before but with black as default color and white when pressed.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/black" />
<item android:state_focused="true" android:color="@color/black" />
<item android:state_pressed="true" android:color="@color/black" />
<item android:color="@color/white" />
</selector>

Now for in the TextView change the text color to the new drawable:

android:textColor="@color/list_item_text"

More on StateListDrawables: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!