public class

RecyclerView.RecycledViewPool

extends java.lang.Object

 java.lang.Object

↳androidx.recyclerview.widget.RecyclerView.RecycledViewPool

Overview

RecycledViewPool lets you share Views between multiple RecyclerViews.

If you want to recycle views across RecyclerViews, create an instance of RecycledViewPool and use RecyclerView.setRecycledViewPool(RecyclerView.RecycledViewPool).

RecyclerView automatically creates a pool for itself if you don't provide one.

Summary

Constructors
publicRecycledViewPool()

Methods
public voidclear()

Discard all ViewHolders.

public RecyclerView.ViewHoldergetRecycledView(int viewType)

Acquire a ViewHolder of the specified type from the pool, or null if none are present.

public intgetRecycledViewCount(int viewType)

Returns the current number of Views held by the RecycledViewPool of the given view type.

public voidputRecycledView(RecyclerView.ViewHolder scrap)

Add a scrap ViewHolder to the pool.

public voidsetMaxRecycledViews(int viewType, int max)

Sets the maximum number of ViewHolders to hold in the pool before discarding.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public RecycledViewPool()

Methods

public void clear()

Discard all ViewHolders.

public void setMaxRecycledViews(int viewType, int max)

Sets the maximum number of ViewHolders to hold in the pool before discarding.

Parameters:

viewType: ViewHolder Type
max: Maximum number

public int getRecycledViewCount(int viewType)

Returns the current number of Views held by the RecycledViewPool of the given view type.

public RecyclerView.ViewHolder getRecycledView(int viewType)

Acquire a ViewHolder of the specified type from the pool, or null if none are present.

Parameters:

viewType: ViewHolder type.

Returns:

ViewHolder of the specified type acquired from the pool, or null if none are present.

public void putRecycledView(RecyclerView.ViewHolder scrap)

Add a scrap ViewHolder to the pool.

If the pool is already full for that ViewHolder's type, it will be immediately discarded.

Parameters:

scrap: ViewHolder to be added to the pool.