Raf*_*ael 54 android android-recyclerview
在使用ListView自定义适配器的旧代码中,我可以使用此代码获取项目.
Message msg = (Message) adapter.getItem(poistion);
Run Code Online (Sandbox Code Playgroud)
现在我正在实施RecyclerView.我如何从中获取物品RecyclerView.adapter?
pde*_*d59 68
你必须自己实现它.
在自定义适配器中添加新方法,您就完成了.
public Message getItem(int position) {
return messageList.get(position);
}
Run Code Online (Sandbox Code Playgroud)
Vol*_*ret 48
我认为正确的方法getItem()是通过RecyclerView LayoutManager.
View v = recyclerView.getLayoutManager().findViewByPosition(position);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
71349 次 |
| 最近记录: |