Question

sorry if there is another question like this but i couldn't find my answer.

I want to know the way to programmatically set a checkbox to state where it is already selected when I populate the ListView. The checkbox is in the Listview and i am using android.R.layout.simple_list_item_multiple_choice.

Any help would be nice, thank you.

Was it helpful?

Solution

There is a method on ListView that you can call to set an item 'checked' state:

for (int i = 0; i < getListAdapter().getCount(); i++) {
    getListView().setItemChecked(i, true);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top