Android: ListView Selector set to null?

我们两清 提交于 2019-12-08 16:25:29

问题


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


回答1:


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




回答2:


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

myListView.setSelector(new ColorDrawable(0x0));



回答3:


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




回答4:


mListView.setSelector(new StateListDrawable());


来源:https://stackoverflow.com/questions/6633374/android-listview-selector-set-to-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!