How to get item from RecyclerView adapter in Android

后端 未结 5 1158
情歌与酒
情歌与酒 2021-02-01 12:37

In old code when I was using ListView with custom adapter I could get item with this code.

Message msg = (Message) adapter.getItem(poistion);
         


        
5条回答
  •  野性不改
    2021-02-01 12:49

    You have to implement it yourself.

    Add a new method in your custom Adapter and you are done.

    public Message getItem(int position) {
      return messageList.get(position);
    }
    

提交回复
热议问题