Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

java - setRecycledViewPool method in 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());

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:

enter image description here

As you can see the types of views for both lists are same.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...