我需要在我的 recyclerView
中获取对特定行的引用。
我以前也是这样
View row = recyclerView.childAt(position);
由于 childAt()
方法是基于 ViewGroup
的,一旦滚动列表,位置就乱了。
我读了here我必须使用返回 ViewHolder
的 recyclerView.findViewHolderForAdapterPosition()
。
如何从 ViewHolder
获取我需要使用的实际 View
?
最佳答案
你应该使用 findViewByPosition
findViewByPosition(int position)
Finds the view which represents the given adapter position.
View row = recyclerView.getLayoutManager().findViewByPosition(YourPosition);
关于Android - 从 RecyclerView.findViewHolderForAdapterPosition() 获取行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46725806/