RecyclerView中的setRecycledViewPool方法 [英] setRecycledViewPool method in RecyclerView

查看:1321
本文介绍了RecyclerView中的setRecycledViewPool方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在以下代码行(其中mrecyclerView是RecyclerView对象)中了解setRecycledViewPool方法与RecyclerView一起实际执行的操作:

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());

我阅读了Android文档链接我仍然不明白它的作用.有人可以向我解释其用途以及何时使用吗?

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(...)可能会很有用.有关详细信息,请参见博客文章.此处添加了相同链接的简短描述.

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.

请考虑以下情况:嵌套的RecyclerView和内部的RecycleView具有相同的视图结构. RecycledViewPool提供了一种无缝方式,可以在这些内部(嵌套)的RecyclerView之间共享视图.

Consider a case where you have a nested RecyclerViews and inner RecycleViews share the same view structure. RecycledViewPool provides a seemless way to share views between these inner (nested) RecyclerViews.

下图中可以看到这种情况的示例:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆