我们的ListView 的点击颜色默认时橘黄色,要想变成自己想要的颜色:
Step1:给ListView设置为
mListView.setSelector(new ColorDrawable(Color.TRANSPARENT));
Step2:在style.xml中添加xml文件,例如叫button_font.xml 在其中添加如下代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@color/blue" />
</selector>
Step3:在ListView 的 Item文件中(记得一定是item文件,不是Listview 的xml文件!),在最外层添加android:background="@drawable/button_font"
完。