我有一个列表选择器,像这样一个简单的列表。ListSelector适用于整个列表
<ListView android:id="@+id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_below="@+id/round"
android:listSelector="#99000000" android:clickable="true" android:cacheColorHint="#00000000" android:background="#00000000">
</ListView>
正如你所看到的android:listSelector =“#99000000”,但“黑阿尔法”颜色应用于整个列表,而不是选定的项目。
因此,这是我现在有,但整个列表中仍然变黑
:: listview_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@drawable/list_normal" />
<item android:state_pressed="true"
android:drawable="@drawable/list_pressed" />
<item android:state_focused="true"
android:drawable="@drawable/list_active" />
</selector>
:: colors.xml
<resources>
<drawable name="list_normal">#96FFFFFF</drawable>
<drawable name="list_active">#66000000</drawable>
<drawable name="list_pressed">#CA000000</drawable>
</resources>
::我的清单中的xml标记
android:listSelector="@drawable/listview_background"
我把文件选择在哪个文件夹? – Breedly 2013-10-04 02:14:15
HoneyComb之前的所有版本中都有一个错误,它将列表选择器** color **应用于整个列表背景。 [查看我对另一个问题的回答](http://stackoverflow.com/a/15873704/383414)了解更多细节。这不是使用图像作为背景的问题,因此下面提供了所有解决方法。 – 2014-07-01 09:57:13