How can I switch the checked state of items in a ListView?

I know that you can graphically switch the checked state of an item in a ListView. But how is this done? I have a ListView containing several CheckedTextView elements and I tried to set the checked state of these elements by calling

list.setItemChecked(arg2, false);

and correspondingly

list.setItemChecked(arg2, true);

This is called in the OnItemClickedListener of my ListView, therefore, arg2is the index of the item that clicked. However, the item is not checked. Is there a call in the Adapter list that I am missing? Or what could it be?

+3
source share
1 answer

What layout are you using for ListItems? android.R.layout.simple_list_item_multiple_choice?

android: choiceMode singleChoice multipleChoice.

+1

All Articles