开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜