Set onItemClickListener inside onBindViewHolder() with RecyclerView.Adapter

后端 未结 5 1067
自闭症患者
自闭症患者 2021-02-14 03:54

I have a custom object :

Student.class

public class Student {
  private String name;
  private String age;

  public String getName() {
    return name;
         


        
5条回答
  •  伪装坚强ぢ
    2021-02-14 04:15

    You can set event Onclick for specific audiences:

    Eg:

     holder.layout.setClickListener(new ItemClickListener() {
      @Override public void onClickItem(int pos) {
        Toast.makeText(context, "CLICK : " + student.getName(), Toast.LENGTH_SHORT).show();
      }
    

提交回复
热议问题