How can i toggle the checked state of items in a ListView?
I know it is possible to graphically toggle the checked state of an item in a ListView. But how is this done? I have a ListView containing several CheckedTextView items, and I'v开发者_如何学运维e tried setting the checked state of these items by calling
list.setItemChecked(arg2, false);
and respectively
list.setItemChecked(arg2, true);
This is called in the OnItemClickedListener of my ListView, so the arg2
is the index of the item clicked. Nevertheless, the item doesn't get checked. Is there a call to the listAdapter that I'm missing? Or what could this be?
What layout are you using for the ListItems? android.R.layout.simple_list_item_multiple_choice?
Your android:choiceMode also has to be set to either singleChoice or multipleChoice.
精彩评论