How do I get the position selected in a RecyclerView?

前端 未结 13 2473
自闭症患者
自闭症患者 2020-11-27 04:40

I am experimenting with the support library\'s recyclerview and cards. I have a recyclerview of cards. Each card has an \'x\' icon at the top right corner to remove it:

13条回答
  •  独厮守ぢ
    2020-11-27 05:05

    @Override
    public void onClick(View v) {
         int pos = getAdapterPosition();
    }
    

    Simple as that, on ViewHolder

提交回复
热议问题