public static abstract class RecyclerView.ViewHolder
extends Object

   ↳ androidx.recyclerview.widget.RecyclerView.ViewHolder

A ViewHolder describes an item view and metadata about its place within the RecyclerView.

RecyclerView.Adapter implementations should subclass ViewHolder and add fields for caching potentially expensive View.findViewById(int) results.

While RecyclerView.LayoutParams belong to the RecyclerView.LayoutManager, ViewHolders belong to the adapter. Adapters should feel free to use their own custom ViewHolder implementations to store data that makes binding view contents easier. Implementations should assume that individual item views will hold strong references to ViewHolder objects and that RecyclerView instances may hold strong references to extra off-screen item views for caching purposes



public final View itemView

Public constructors

ViewHolder(View itemView)

Public methods

final int getAbsoluteAdapterPosition()

Returns the Adapter position of the item represented by this ViewHolder with respect to the RecyclerView's RecyclerView.Adapter.

final int getAdapterPosition()

This method is deprecated. This method is confusing when adapters nest other adapters. If you are calling this in the context of an Adapter, you probably want to call getBindingAdapterPosition() or if you want the position as RecyclerView sees it, you should call getAbsoluteAdapterPosition().

final Adapter<? extends RecyclerView.ViewHolder>