I want to create an expandable listview with checkboxes present in the groups as well as the children. What I want is, the user may check the group in order to select all th
Try this sample Code Expandable CheckList
To do this you will need to include boolean
flag in each object, or in you adapter create two list views (for groups and items) that will contain selected items.
I would rather add boolean
like this :
class Group{ ...
boolean isSelected;
}
class Item { ...
boolean isSelected;
}
Then in Adapter
in getViews()
methods:
getItemView(...){
...
itemHolder.checkbox.setSelected(item.isSelected)
}
getGroupView(...){
...
groupHolder.checkbox.setSelected(group.isSelected)
//add lisener
itemHolder.checkbox.setOnCheckedChangeListener(lisener);
}
And on group check you can do something like this :
void selectGroup(Group group){
for(Item item: group.getItems()){
item.isSelected = true;
}
//update your list
notifiDataSetChanged();
}
That's all what you need
UPDATE :