Adil Waqar Adil Waqar - 1 year ago 76
Android Question

Selecting All Items in a Listview on checkbox select

I am using simple listView with


I have added a checkbox and on its checked event want all list items to get selected and on unchecked all items to get unselected..
Here is the code..

CheckBox select_all = (CheckBox) dialog.findViewById(;
arrayAdapter = new ArrayAdapter<String>
(ctx,android.R.layout.simple_list_item_multiple_choice,readyToDownload );

select_all.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// check all list items
// unselect all list items


Answer Source
for ( int i=0; i < listview.getChildCount(); i++) {
   listview.setItemChecked(i, true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download