ListView selection remains persistent after exiting choice mode

后端 未结 11 868
青春惊慌失措
青春惊慌失措 2020-11-29 01:45

I have a ListView subclass that I allow selections on when the context action bar (CAB) is active. The CAB is set as a callback to the onItemLongClick event:

11条回答
  •  没有蜡笔的小新
    2020-11-29 02:02

    Looking at the ListView sourcecode, the only way to work around this is to set the ListView to CHOICE_MODE_NONE, then re-assign the ListAdapter (which clears the internal selection list regardless of choice mode)

    i.e. in a ListFragment/ListActivity

    getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
    getListView().setAdapter(getListAdapter())
    

提交回复
热议问题