RecyclerView Checkbox Android Example Get Checked Item Position

Warm welcome to RecyclerView Checkbox Android Studio example.

In this RecyclerView Checkbox Android example, we will cover single selection, multiple selection and also select all scenario.

There is a common problem like “checkbox unchecked when I scroll recyclerview.” We will solve this problem in this  RecyclerView Checkbox Android tutorial.

We will also send selected or checked items to next activity.

You can learn how to use onItemClickListener, onClickListener, onItemTouchListener etc. for recyclerview.

If you have not implement basic recyclerview with custom adapter yet, check recyclerview android example first.

Also checkout,

Now checkout the output of RecyclerView Checkbox Android example, then we will develop it.

Download Source Code for RecyclerView Checkbox Android example

Step 1: Create a new project in Android Studio.

Prepare a new project in android studio with empty activity.

Step 2: Updating build.gradle(Module:app) file

Add below source code into dependencies{}

Step 3: Coding cardview.xml

Create a new file into drawable folder and name it cardview.xml

Add below source code into it.

Step 4: Making rv_item.xml

Create a new layout resource file named rv_item.xml

Copy following source code into it

Step 5: Making Model class

Create a new JAVA class named Model.java and paste below

Step 6: Adding integer.xml

Create a new file named integer.xml  in values directory and add below

Step 7: Code for CustomAdapter.java

Let’s create Custom Adapter for RecyclerView.

Make a new JAVA class named CustomAdapter.java and add below

Describing CustomAdapter

Above code will set a tag for position.

Now look at below source code

We will get position (which we set above using setTag() method) in onClick method.

Step 8: Making NextActivity

Create a new activity named “NextActivity

Add below source code into NextActivity.java

Copy following code into activity_next.xml

Step 9: Finally Update activity_main.xml and MainActivity.java

Updating activity_main.xml

Add following into activity_main.xml

Updating MainActivity.java

Copy folowing into MainActivity.java

So all for RecyclerView Checkbox Android tutorial. Thank you.

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...

9 Responses

  1. Sankar says:

    I found your source code, actually my adBlocker was blocking it. superior logic, simple yet effective. Great work.

  2. vaibhav says:

    Thank uthis help me alot..

    pls help me to solve one more prob.
    when i change orientation my checkboxes in cardview get unchecked.

  3. Smita P says:

    Hi…

    May i Know how to store the values in firebase database with the help of Checkbox?

  4. Christy Harris says:

    Great tutorial, helped me a lot. +1 (if I could)

  5. Devil says:

    Where is The Source Code Link..??????

    • Hardik Parsania says:

      Soon after intoduction video.
      It is locked by default. Like Our facebook page to unlock download source code button. Cheers!

Leave a Reply

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