-3

I have a problem with ListView background on android 2.3.3 (android 4 no problem). When click on list item, changes ListView background to @color/holo_green from android:listSelector attribute. How to resolve this problem?

my_list.xml

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:drawSelectorOnTop="false"
    android:alwaysDrawnWithCache="false"
    android:cacheColorHint="@android:color/transparent"
    android:listSelector="@drawable/sa_list_item_selector"
    android:divider="@drawable/sa_list_divider"/>

Adding android:background="@android:color/transparent" nothing changes

sa_list_item_selector.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/holo_green" />
    <item android:drawable="@android:color/transparent" />
</selector>
4

1 回答 1

0

Maybe try to change:

<?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/holo_green" />
    <item android:drawable="@android:color/transparent" />
</selector>

To:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@android:color/transparent" />
    <item android:drawable="@color/holo_green" />
</selector>

Look at your selector. The code is there.

于 2013-07-08T13:41:27.743 回答