我有一個列表選擇器,像這樣一個簡單的列表。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