Android: ListView Selector set to null?
Asked Answered
L

4

9

I want to disable the Selector from my ListView. That's when I click any items there will be no indication that it has been clicked.

I tried this in my ListView tag: android:listSelector="@null" and didn't work

Liris answered 9/7, 2011 at 7:22 Comment(2)
do u mean u want to remove orange color effect when clicking listview item ???Wanhsien
Yes. It differs from one phone to another. But it is orange in some cases.Liris
C
24

set this android:listSelector="#00000000" Try this.

Coworker answered 22/7, 2011 at 9:11 Comment(1)
Why not use @android:color/transparent instead #00000000?Ultrastructure
C
6

The above answer from Kalpana is correct. You can also do it in code like this:-

myListView.setSelector(new ColorDrawable(0x0));
Complicate answered 2/11, 2012 at 9:31 Comment(0)
L
0

You could create a new drawable to use as selector, that wouldn't have any state in it :

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/background_dark" />
</selector> 

and then set it using the android:listSelector attribute. You can reference one of the android colors as the background color in your selector : http://developer.android.com/reference/android/R.color.html

Liuka answered 9/7, 2011 at 8:33 Comment(0)
R
0
mListView.setSelector(new StateListDrawable());
Rabble answered 7/9, 2015 at 5:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.