質問

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