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

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

问题描述

我试图了解 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 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天全站免登陆