Android ListView Checkbox

Android ListView Checkbox

Hi to all, today we are going to learn how to enable multiple items to be chosen in ListView, GridView and in RecyclerView using CheckBox, you’ll configure the ListView to display a checkbox next to each item. You can combine many components like TextView, CheckBox, ImageView, etc. and can make ListView as you require.


  1. Material Tabs Tutorial
  2. ListView Tutorial
  3. GridView Tutorial
  4. RecyclerView Tutorial


In this tutorial, we are going to learn how to enable multiple items to be chosen in ListView, GridView and in RecyclerView using CheckBox.


1. Create a new project in Android Studio by navigating to File ⇒ New ⇒ New Project and fill required details. By default my activity is

2. Open build.gradle and include this libraries show below:

3. Now create 3 material tabs naming ListView, GridView and RecyclerView. For this you can check this link for reference.

4. After creating tabs lets move to creating xml layouts for individual tabs.

  • list_view_frament.xml
  • grid_view_fragment.xml
  • recycler_view_fragment.xml
5. In all the above xml layouts i am using one common layout i.e. bottom_container.xml. Lets create the common layout xml, this layout contains three buttons for implementing actions over selected rows.
6. Now lets create java classes for all the above three xml files.

In all the three above Java classes the main thing that we need to focus is button click events:

  • Show Button : This button used to show a Toast of checked rows.
  • Delete Button : This button is to delete checked rows.
  • Select All/Deselect All Button : This button is to select and deselect all the rows.
7. Now after creating all fragment classes we have to create Adapters for ListView, GridView and RecyclerView.

In both the above adapter the common code is to select rows:
8. Finally all things done. Now you can also make your any type of multiple choice list view.

Thanks. 🙂

Download Source Code


About the author

I am an Android developer for whom Android is the one and only love. I work as a freelancer which gets me and Android closer. I always love to share my learnings and love to learn from others knowledge too.


Hi nice work
i have the same work to do ,
me i used database SQLITE , so i have table product(id_product, name_product, image_product, namecategory) so in my first interface “fragment” i choos my category with image_category “the image it will be stock in drawable” and after when i click in one category like fruit so one spinner”listProduct” it will be open with the list of fruit i can do multi check for some product i want and i valide so when i valide it will stock in table and show in another fragment name “list”. So my problem that what is the solution should used after valide to return choose another category like vegetables and i click in image so interface “listProduct” it will be open again but with list of vegetables i check what i want like potato,peas and i valide so this list of Vegetables it will be add to list of fruits and when i click show list i can see the finally list , How can do it ?? The greate solution hope can help me thanks


How to catch the Item Click inside Fragment?

    Hi Nestor,

    Item click inside Fragment will be implemented same like we do in Activity.


      Good, I am just trying to do it but seems not work. The setOnItemClickListener is not firing.


Hi, I’ve got issue .. i’ve implement your code into my code..
In my code, assume I have database List 100 array data in my checkbox list [0, 1, 2, 3, 4, 5……100]. after that I am check it in [2,4,5].. when debug I am just get value [2,4] .. it mean I didn’t get value of 5. can you help me please?\
thank you

    Hi Obie,

    Can you check your code that 5th number item is checked or not? And if checked use some other cases like checking more items and debug and check if you are getting checked ones or not?

    If still the issue is there then mail me your code/classes ay mail id. You can find it on the top of the blog.



there has to be a easier way, rigth ? is many code for simple checkbox in a gridview :c

    Hi Lyon,

    The code contains Listview, gridview and recyclerview example. May be due to that you feeling it’s too many code.
    And also for listview and gridview I am using same code.



You can update this sample at Android 3.3 pls ????

    Hi Lyon,

    What issue you are facing in current code?


Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)