문제

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