I have a custom object :
Student.class
public class Student {
private String name;
private String age;
public String getName() {
return name;
You can implement onClickListener
for the parent view like below:
//holder.view - parent layout inside recyclerView item
holder.view.setTag(position);
holder.view..setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int pos = (int) v.getTag();
Student student = students.get(pos);
// Do your operation
}
});
OR
if you want to set onItemClickListener
from activity/fragment
where recyclerView
is initialised, you can follow this link: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/