Why does OnClickListener on a ViewHolder don't work?

前端 未结 3 1529
孤街浪徒
孤街浪徒 2020-11-30 06:36

I\'m trying to implement a way to handle item selection on a RecyclerView. I personally don\'t like the way suggested in some answers on SO of passing through g

3条回答
  •  醉话见心
    2020-11-30 07:23

    You can do it in your onBindViewHolder

             @Override
            public void onBindViewHolder(ReportViewHolder holder, int position {
          holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View arg0) { 
            // handle your click here. 
        } }); 
    }
    

提交回复
热议问题