我想将选择器应用到我的列表视图,它是一个自定义列表视图,我尝试了很多选项,但没有任何工作。任何帮助将不胜感激。我附上我的代码。由于提前Android:ListView选择器工作不正常
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>
黄色背景效果有效地进行,但蓝效果不发生,请帮助 谢谢提前
yup..it默认项
<item android:drawable="@drawable/your_default_background_for_row_item" />
奋力...非常感谢 – Rohan,我有他们的孩子被扩展所有time.all我想要做的是另一种可扩展列表视图中,选择添加给他的孩子,只要他们被点击,就像我们在正常列表视图中一样。有可能 – Rohan
同样的事情会起作用。请不要将此选择器设置为标题布局的背景。 –