In Listview, we just do something like this :
It means, we just do something like code above on class that declare the listview. It's a little bit simple than Recyclerview.
How about on Recyclerview?
Actually there are many ways to implement onClickListener in RecyclerView. If you ask at Stackoverflow, they will give many answers to do this.
From this article i will give you one of many way how to implement onClickListener in RecyclerView.
I do this on Adapter class. For simply, give an ID on RelativeLayout or LinearLayour in your Adapter's layout.
After that, define the LinearLayour or RelativeLayout in your Holder. Next, do the OnClick in onBindViewHolder method.
For simply, is using this project for example, inside OnBindViewHolder method just do like below :
Done! Hope it helps, thank you.