Android ExpandableListView Checkbox Example Handle Multiple Selection

Android ExpandableListView Checkbox Example is covered in this post.

We will put checkboxes in the child rows of expandable listview.

We will solve the general problems like

  1. checkbox gets unchecked while scrolling the listview
  2. Different positioned or multiple checkboxes are checked when click on single box

In this example, we will put checkbox in both parent and child row.

If you click on parent checkbox then all it’s child rows will be also checked. But you can also check few rows of child from the same parent as well.

First, see the output of the tutorial then we will develop it step by step.

Download Source Code For Android Expandablelistview Checkbox

Click following link and download your source code

Step 1. Create project in Android Studio.

Make a new project in android studio with empty activity as the default activity.

Step 2. Update colors.xml

Update your colors.xml file with following

Step 3. Adding Images

Download Images by Clicking following link

It contains three images,

  1. icon_checked,
  2. icon_unchecked and
  3. icon_dot

Now, put icon_dot into mipmap folder and copy icon_checked and icon_unchecked into drawable folder.

See below image for reference

android expandablelistview checkbox

Step 4. Adding files in drawable

Make a new layout xml named background_bordered_theme.xml and add below source code in it

Now create another layout xml file and give it a name custom_checkbox_theme.xml

Copy below code into it

Prepare third xml file named edit_text_theme.xml

Code for this file is like

Step 5. Making layout resources files

Create a new layout resource xml file in res->layout folder. It will be called child_list_layout_choose_category.xml

It’s code seems like

Make second xml file in res->layout folder and give it sweet name like group_list_layout_choose_categories.xml

Add below code in it

Prepare last xml file in res->layout and gibe its name group_list_layout_my_categories.xml

Step 6. Making Model Classes

Make a new folder called Model in app->java->your package name (It is the same path where your MainActivity is present)

See below image where you need to put required JAVA classes

android expandablelistview checkbox

Create a new JAVA class named in Model folder

Add Code for it like

Make a second Model class named in Model folder

Add following code in it

Make a new JAVA class named “” at the path shown in above image

Code for this class will look like

Prepare another JAVA class named

Add below source code in it

Step 7. Update Main Activity

Finally, update activity_main.xml like below

And replace code of with following

Now run your project and enjoy playing with checkboxes in expandable listview.

Support us by sharing our tutorials with other learners.

Thanks and have a nice day!

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

12 Responses

  1. Riz says:

    Hi, thanks you have really very nice and helpful I used this guide and everything work fine, I want to add a clicklistener on childItem so when the child is clicked the checkbox will checked or unchecked based on previous selection. Waiting for your reply, bundle of thanks.

    • Hardik Parsania says:

      Click listener for child view is already present in adapter class.
      It is as below

      viewHolderChild.cbSubCategory.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
      if (viewHolderChild.cbSubCategory.isChecked()) {
      count = 0;
      childItems.get(groupPosition).get(childPosition).put(ConstantManager.Parameter.IS_CHECKED, ConstantManager.CHECK_BOX_CHECKED_TRUE);
      } else {
      count = 0;
      childItems.get(groupPosition).get(childPosition).put(ConstantManager.Parameter.IS_CHECKED, ConstantManager.CHECK_BOX_CHECKED_FALSE);

      for (int i = 0; i < childItems.get(groupPosition).size(); i++) { if (childItems.get(groupPosition).get(i).get(ConstantManager.Parameter.IS_CHECKED).equalsIgnoreCase(ConstantManager.CHECK_BOX_CHECKED_TRUE)) { count++; } } if (count == childItems.get(groupPosition).size()) { parentItems.get(groupPosition).put(ConstantManager.Parameter.IS_CHECKED, ConstantManager.CHECK_BOX_CHECKED_TRUE); notifyDataSetChanged(); } else { parentItems.get(groupPosition).put(ConstantManager.Parameter.IS_CHECKED, ConstantManager.CHECK_BOX_CHECKED_FALSE); notifyDataSetChanged(); } ConstantManager.childItems = childItems; ConstantManager.parentItems = parentItems; } });

  2. Riz says:

    Thanks Hardik, but i want if someone in childlist click on the name of item the corresponding checkbox will be checked aur unchecked, now it work only if i click on the checkbox. thanks.

    i have added clicklistner on tvSubCategoryName where i Toast the the but at same time i want that checkbox will be check aur unchecked.

    viewHolderChild.tvSubCategoryName.setOnClickListener(new View.OnClickListener()


  3. Riz says:

    Thanks Hardik, but i want clicklistner on tvSubCategoryName that can check and uncheck the corresponding checkbox. Thanks

  4. Riz says:

    Hi thanks fo Hardik, i want clicklistioner on tvSubCategoryName that can select and unselect the checkbox.

    • Hardik Parsania says:

      In example i have put onclick on checkbox, if you want to have onclick on textview then try something like this

      put same code here which is present in the cbSubCategory.setonclick method

      Let me know if it works or not

  5. Riz says:

    Thanks Hardik, Clicklistner work on textview but i am unable to select or deselect the checkbox. can you help me to do this. thanks again.

  6. Riz says:

    yes but not work and i am unable to understand how di you check and uncheck the box. waiting for replay, bundle of thanks

  7. Riz says:

    Hardik Parsania, can you help me to sort out the issue. Thanks



    Am not able to download the source code. Could you please share via Email

    • Hardik Parsania says:

      First like demonuts facebook page, then refresh your browser.
      If you are still not able to download, then reply me, I will send you on email.

Leave a Reply

Your email address will not be published. Required fields are marked *