开发者

How can i toggle the checked state of items in a ListView?

开发者 https://www.devze.com 2023-02-16 18:48 出处:网络
I know it is possible to graphically toggle the checked state of an item in a ListView. But how is this done?

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

精彩评论

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