I am calling clear on my arrayadapter:

adapter.clear();

Also did:

adapter.notifyDataSetChanged();

However when I ask the list view that is bound to that adapter for its checked items I still get checked items back.

listView.getCheckedItemPositions();

The view of the list is changing (its cleared on the UI) which is perfect. But why is the listviews checked items not getting updated?

有帮助吗?

解决方案

The adapter.clear() automatically call notifyDataSetChanged() (default behavior, I don't know if you changed). You don't need to use it again. Adapter and listview are diferents things, you could want to change the itens from adapter without change the checked itens. That is why the checked itens are not unchecked.

You can use listView.clearChoices().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top