Pergunta

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?

Foi útil?

Solução

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().

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top