1
votes

I need the checkboxes in my listview checked by default so that it returns true for the value of isChecked().

I am using the Simple Multiple choice list item layout provided by the sdk supplied in android.R.layout.simple_list_item_multiple_choice

I have set the ListView adapter like this:


adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_multiple_choice, list);

setListAdapter(adapter);


1

1 Answers

2
votes

I have used the following code for Setting the Check boxes Default Checked in my application

adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice, list);
setListAdapter(adapter);
l1 = getListView();
for (i = 0; i < getListAdapter().getCount(); i++) {
l1.setItemChecked(i, true);
}

and the output, listview came with multiple check boxes default checked