In this lecture we will describe about how we can Handle Click Events and Delete value in RecyclerView ,and also describe what is RecyclerView. Why we use it. After reading this lecture you will also able Understand how to handle  click events and deleting value in RecyclerView.


If you not understand this lecture. Handling click events and deleting value in RecyclerView.You should also read my previous lectures How to Create Project – Material design and RecyclerView in Material Design(Part 1) .These lecture are interrelate of each other.


Google has introduced visual component to enhance the application development.The new interface is material design.Which consists of RecyclerView and CardView. But These component are available in android Lollipop API . RecyclerView is more advance version of list view and Recycler view is more flexible as compare to list view. Recycler view is used when list that is to be changed dynamically. For more detail about how you create RecyclerView in material design click on RecyclerView in material design.


  • How to add Click Events and deleting value in RecyclerView
  • How to run the app in your Emulator

Implementation Section

  1.   We  will describe how can handle click events in RecyclerView.
  2. We will also describe how can delete value in RecyclerView.

So this is a work that will done in this section.please read this lecture carefully all the detail is provides step by step.First of you will open navigationDrawerFragement .java class file and inside the getData method. You want to see icons id and title contain four elements.So our main goal is repeat icon id and title in number of time and we use for loop which start from initial condition  and invoke 100 time. Also used model operator i% for right element over the array for you number of want .This is a code that is used for repeat the icon id and tittle in number of time.

After this set you will open viewAdpeter .java class file and inside the onCreateViewHolder and
onBindViewHolder method you want to add log method and run the application. You want to see in logcat after using(log method) describe the position of every element of icon id  and title for more information of log method please click on detail of log method.Two method in which used log method are below.

After this step we handle click event on icon id and title and used setOnClickListener method. When user click on icon id and title show the position on emulator which item user will selected.That are show below.

After Completing on click events on RecyclerView in Material design.Next step is how can delete value form RecyclerView.This is very simple we create a method of delete. which consists of one parameter( position).
public void delete(int position) this method only used for  accept the position which item user will delete.In RecyclerView we used method to delete public void final notifyItemRemoved() This method is used for structural change and delete items from position.This is code that is used for delete value from recyclerView.

After completing this step you will open a Class file and write the following code.

After completing this step you will open Class file and write the following code.

Run the Application

Alt Tag RecyclerView in material design2


In this lecture we learned about how we can handle click events and delete value in android studio. In this lecture Our  main focus  was  how to make it simple while using the same predefined method and how to check the position of the specific file by clicking it just. I hope you will understand this lecture. Thank you for reading this lecture Hope you got the idea.


  • Mario German Agudelo

    Hi James, thanks for sharing your knowledge: I have an application which has two buttons on the main activity, the idea is that by giving click on them, I send activity recyclerview which would be the same for the two buttons, the only thing is that by giving click button 1 to display information only on that button and the button 2 to give click to show only the information that button, I appreciate all the information you can give me, thank you.