Skip to content

Most visited

Recently visited

added in version 22.1.0
belongs to Maven artifact


public static abstract class RecyclerView.ViewCacheExtension
extends Object


ViewCacheExtension is a helper class to provide an additional layer of view caching that can be controlled by the developer.

When getViewForPosition(int) is called, Recycler checks attached scrap and first level cache to find a matching View. If it cannot find a suitable View, Recycler will call the getViewForPositionAndType(Recycler, int, int) before checking RecyclerView.RecycledViewPool.

Note that, Recycler never sends Views to this method to be cached. It is developers responsibility to decide whether they want to keep their Views in this custom cache or let the default recycling policy handle it.


Public constructors


Public methods

abstract View getViewForPositionAndType(RecyclerView.Recycler recycler, int position, int type)

Returns a View that can be binded to the given Adapter position.

Inherited methods

From class java.lang.Object

Public constructors


added in version 22.1.0
RecyclerView.ViewCacheExtension ()

Public methods


added in version 22.1.0
View getViewForPositionAndType (RecyclerView.Recycler recycler, 
                int position, 
                int type)

Returns a View that can be binded to the given Adapter position.

This method should not create a new View. Instead, it is expected to return an already created View that can be re-used for the given type and position. If the View is marked as ignored, it should first call stopIgnoringView(View) before returning the View.

RecyclerView will re-bind the returned View to the position if necessary.

recycler RecyclerView.Recycler: The Recycler that can be used to bind the View

position int: The adapter position

type int: The type of the View, defined by adapter

View A View that is bound to the given position or NULL if there is no View to re-use

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)