RecyclerView Button Android Studio Example Get Click Position

Welcome guys to RecyclerView Button Android Studio Example.

In this RecyclerView Button Android tutorial, you will learn to make recyclerview with button in it’s row item.

You will learn to “handle button click inside a row in recyclerview” in RecyclerView Button Android tutorial.

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

Other useful tutorials,

Official guide for recyclerview : RecyclerView Official

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

Download Source Code for RecyclerView Button Android example

[sociallocker] Download recycler_button_code[/sociallocker]

Step 1: Create a new project in Android Studio.

When you create a new project in android studio, make default activity as an 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 source code

Step 6: Adding integer.xml

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

Step 7: Code for CustomAdapter.java

Let’s create Custom Adapter for RecyclerView.

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

Describing CustomAdapter

We will set tags for Plus and Minus button with below source code


Following is the onClick method for Plus button

Following is the onClick method for Minus button

Step 8: Making NextActivity

Create a new activity named “NextActivity

Add following source code into NextActivity.java

Paste following code into activity_next.xml

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

Updating activity_main.xml

Make following code into activity_main.xml

Updating MainActivity.java

Copy following into MainActivity.java

Please share this tutorial with friends.

Your sharing will help other in their path to android development.

Also you can use the comment section for any queries.

So all for RecyclerView Button 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...

16 Responses

  1. Carel says:

    Thank you for a great tutorial. I copies and pasted the code just as it is to test it out, and the app crashes when the next activity button is clicked.

  2. dany says:

    can you share your source code

  3. Ankesh kumar says:

    please share code of above video i will be thankful

  4. Ehtisham says:

    where is the sourse code

  5. Gabs says:

    Man, can you please validate this page, is the only one that doesnt show the like button to enable the download source code button.

  6. Monu Kumar Malav says:

    recycle view one item selected than second time web service call auto item selected sovled this problam …….

Leave a Reply

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