RecyclerView 中的 setRecycledViewPool 方法 [英] setRecycledViewPool method in RecyclerView
问题描述
我试图了解 setRecycledViewPool 方法与以下代码行中的 RecyclerView 一起实际做什么,其中 mrecyclerView
是一个 RecyclerView 对象:
mrecyclerView.setRecycledViewPool(new RecyclerView.RecycledViewPool());
我阅读了 Android 文档
如您所见,两个列表的视图类型相同.
I am trying to understand what the setRecycledViewPool method actually does along with the RecyclerView in the following line of code where mrecyclerView
is a RecyclerView object:
mrecyclerView.setRecycledViewPool(new RecyclerView.RecycledViewPool());
I read the Android documentation link and I still don't understand what it does clearly. Can someone explain to me its use and when to use it?
setRecycledViewPool(...)
can be useful when we have a nested RecyclerView. See this blog post for details. A short description of the same link is added here.
Consider a case where you have a nested RecyclerView
s and inner RecycleView
s share the same view structure. RecycledViewPool
provides a seemless way to share views between these inner (nested) RecyclerView
s.
An example of such case could be seen in the following image:
As you can see the types of views for both lists are same.
这篇关于RecyclerView 中的 setRecycledViewPool 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!