Android RecyclerView CLick Listener Tutorial

In Our Previous tutorial “Android RecyclerView Tutorial” . We had learned how to render a simple RecyclerView with a custom layout. We had also learn writing a adapter class and binding data the list of books displaying the title and author .

If you’ve used a RecyclerView, you may know that they don’t have a setOnItemClickListener as ListView had, so we have to create our own way to do it . There are many ways to achieve this, but I will show you the way I usually do it .

Let’s Get it Working

In this tutorial we are going to learn how to add recycler view item click listener. I assume that you have learned how to render a simple RecyclerView with a custom layout from my previous post “Android RecyclerView Tutorial” .

Step 1 ) Writing the click interface

Create an interface named RecyclerViewClickListener.java and add below code. Here we declare two methods onClick and onLongClick to identify item click and long click respectively.