I have a custom object :
Student.class
public class Student {
private String name;
private String age;
public String getName() {
return name;
replace this code,
@Override public void onBindViewHolder (ViewHolder holder,int position){
final Student student = students.get(position);
holder.name.setText(student.getName());
holder.age.setText(student.getAge());
holder.v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context, "CLICK : " + student.getName(), Toast.LENGTH_SHORT).show();
}
});
holder.v.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Toast.makeText(context, "CLICK : " + student.getName(), Toast.LENGTH_SHORT).show();
return false;
}
});
}