RecyclerView android: Getting an item at a particular position

▼魔方 西西 提交于 2019-12-05 10:10:28

You can add your own method to RecyclerView or I would suggest the RecyclerView.Adapter itself.

For instance, for ListView, you have:

@Override
public Object getItem(int position) {
    return listData.get(position);
}

You can add the same thing to your RecylcerView.Adapter or access it another way by adding a simple method to your RecylcerView.Adapter:

public List<Model> getList() {
    return this.mModel;
}

Use it like this:

recyclerView.getAdapter().getList().get(position)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!