I use a ListView
in my layout like this:
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:layout_centerInParent="true"
android:divider="@color/dark_grey"
android:drawSelectorOnTop="false"
android:focusable="true"
android:layout_marginBottom="55dp"
android:cacheColorHint="#00000000"
android:listSelector="@color/light_grey"
android:dividerHeight="1px" />
The selector works great but how can I disable the selector?
I tried:
listView.clearChoices();
listView.setSelected();
listView.setSelector();
...
and a few more things but nothing works. Any ideas how I can turn my selected item back to normal? Can't be that complicated, right?
Edit: I need a programmatical solution!
Thanks!
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.
For me it worked with:
listView.setAdapter(myAdapter);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With