I use a ListView
in my layout like this:
In your XML where you declare the ListView use:
<ListView android:id="@+id/my_list" android:listSelector="#00000000" />
Call requestLayout()
on the ListView
after clearChoices()
. It will work.
As @Muerte mentioned above, doing the following worked for me:
myListView.clearChoices();
myAdapter.notifyDataSetChanged();
That seems like it would be better than redrawing the whole layout.
try this
Create your own selector xml file like this
YourSelector.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/item_disabled" />
<item android:state_pressed="true"
android:drawable="@drawable/item_pressed" />
<item android:state_focused="true"
android:drawable="@drawable/item_focused" />
</selector>
check out this link
here
Nothing of the solutions actually worked for me. My listview is for listing the searched items and has a provision to redo the search. On getting the result I added the following code snippet and it worked :)
myAdapter.setSelectedIndex(-1);
You can set a selector after click:
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/transparent_white" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/transparent_white" android:state_focused="false" android:state_pressed="true"/>
<item android:drawable="@drawable/transparent_white" android:state_focused="true"/>
<item android:drawable="@drawable/transparent_white" android:state_focused="false"/>
and the @drawable/transparent_white is #00ffffff