我正在尝试将选择器应用到我的列表视图中,它是一个自定义列表视图,我尝试了很多选项但都不起作用。非常感谢任何帮助。我附上了我的代码。提前致谢。
selector_listview.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="@drawable/faintblue" />
<item android:state_focused="true" android:drawable="@drawable/yellow" />
</selector>
layout_listview.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >
<ListView
android:id="@+id/lvChatList"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/rlHeader"
android:background="@drawable/selector_expandable_listview"
android:listSelector="@drawable/selector_expandable_listview" >
</ListView>
<TextView
android:id="@+id/tvNoChats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="No Chats"
android:visibility="gone" />
</RelativeLayout>
黄色背景效果有效,但蓝色效果不起作用,请帮忙解决。 提前感谢。