How to get item from RecyclerView adapter in Android

后端 未结 5 1121
情歌与酒
情歌与酒 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:45

    I think the correct way to getItem() is through RecyclerView LayoutManager.

    View v = recyclerView.getLayoutManager().findViewByPosition(position);
    

提交回复
热议问题