Home Ask Login Register

Developers Planet

Your answer is one click away!

Viren February 2016

Android: Expandable ListView with parent checkbox and child checkbox

I want to create a expandable listview with parent checkboxes and child checkboxes. Whenever a parent checkbox is selected all the child checkboxes should also be selected. Similarly whenever child checkboxes are selected/unselected the parent checkboxes should behave appropriately.

I have tried with below Adapter code after referring to this link Create expandable listview with group and child checkbox.

public class FilterListExpandableListItemAdapter extends BaseExpandableListAdapter {

private Map<ExpListGroupItem, List<ExpListChildItem>> groupChild;
private List<ExpListGroupItem> groups;
private Activity context;
private ExpandableListView elv;

public FilterListExpandableListItemAdapter(Activity context, List<ExpListGroupItem> cities,
                             Map<ExpListGroupItem, List<ExpListChildItem>> cityArea, ExpandableListView elv) {
    this.context = context;
    this.groupChild = cityArea;
    this.groups = cities;
    this.elv = elv;

public int getGroupCount() {
    return groups.size();

public int getChildrenCount(int groupPosition) {
    return groupChild.get(groups.get(groupPosition)).size();

public Object getGroup(int groupPosition) {
    return groups.get(groupPosition);

public Object getChild(int groupPosition, int childPosition) {
    return groupChild.get(groups.get(groupPosition)).get(childPosition);

public long getGroupId(int groupPosition) {
    return groupPosition;

public long getChildId(int groupPosition, int childPosition) {
    return childPosition;

public boolean hasStableIds() {
    return true;

public View getGroupView(int groupPosition, boolean isE        


Ragesh Ramesh February 2016

In your getChildView method you should check if parentcheckbox is selected and if yes then


Post Status

Asked in February 2016
Viewed 1,384 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life