您的位置:首页 > 其它

ListView Item 选中时 改变 TextView 的字体颜色

2011-07-15 14:31 561 查看
在国内网上找了半天也没找到解决方案,还是stackoverflow给你,我是参考一些自己试试了,不用重写adapter来改变 TextView的字体颜色

文件名:list_item_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="@color/green" /> <!-- focused -->
<item android:state_pressed="true" android:color="@color/green" /> <!-- pressed -->
<item android:state_selected="true" android:color="@color/green" /> <!-- pressed -->
<item android:color="@color/red" /> <!-- default -->
</selector>

文件名:list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp">

<TextView
android:id="@+id/listItem_TV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@drawable/list_item_selector"
/>

</LinearLayout>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: