O Google tem o compromisso de promover a igualdade racial para as comunidades negras. Saiba como.

Adapter

abstract class Adapter<VH : RecyclerView.ViewHolder!>
kotlin.Any
   ↳ androidx.recyclerview.widget.RecyclerView.Adapter

Base class for an Adapter

Adapters provide a binding from an app-specific data set to views that are displayed within a RecyclerView.

Summary

Nested classes

Defines how this Adapter wants to restore its state after a view reconstruction (e.g. configuration change).

Public constructors

Base class for an Adapter

Public methods
Unit
bindViewHolder(@NonNull holder: VH, position: Int)

This method internally calls onBindViewHolder(ViewHolder, int) to update the ViewHolder contents with the item at the given position and also sets up some private fields to be used by RecyclerView.

VH
createViewHolder(@NonNull parent: ViewGroup, viewType: Int)

This method calls onCreateViewHolder(ViewGroup, int) to create a new ViewHolder and initializes some private fields to be used by RecyclerView.

open Int
findRelativeAdapterPositionIn(@NonNull adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder!>, @NonNull viewHolder: RecyclerView.ViewHolder, localPosition: Int)

Returns the position of the given ViewHolder in the given Adapter.

abstract Int

Returns the total number of items in the data set held by the adapter.

open Long
getItemId(position: Int)

Return the stable ID for the item at position.

open Int
getItemViewType(position: Int)

Return the view type of the item at position for the purposes of view recycling.

RecyclerView.Adapter.StateRestorationPolicy

Returns when this Adapter wants to restore the state.

Boolean

Returns true if one or more observers are attached to this adapter.

Boolean

Returns true if this adapter publishes a unique long value that can act as a key for the item at a given position in the data set.

Unit

Notify any registered observers that the data set has changed.

Unit

Notify any registered observers that the item at position has changed.

Unit
notifyItemChanged(position: Int, @Nullable payload: Any?)

Notify any registered observers that the item at position has changed with an optional payload object.

Unit

Notify any registered observers that the item reflected at position has been newly inserted.

Unit
notifyItemMoved(fromPosition: Int, toPosition: Int)

Notify any registered observers that the item reflected at fromPosition has been moved to toPosition.

Unit
notifyItemRangeChanged(positionStart: Int, itemCount: Int)

Notify any registered observers that the itemCount items starting at position positionStart have changed.

Unit
notifyItemRangeChanged(positionStart: Int, itemCount: Int, @Nullable payload: Any?)

Notify any registered observers that the itemCount items starting at position positionStart have changed.

Unit
notifyItemRangeInserted(positionStart: Int, itemCount: Int)

Notify any registered observers that the currently reflected itemCount items starting at positionStart have been newly inserted.

Unit
notifyItemRangeRemoved(positionStart: Int, itemCount: Int)

Notify any registered observers that the itemCount items previously located at positionStart have been removed from the data set.

Unit

Notify any registered observers that the item previously located at position has been removed from the data set.

open Unit
onAttachedToRecyclerView(@NonNull recyclerView: RecyclerView)

Called by RecyclerView when it starts observing this Adapter.

abstract Unit
onBindViewHolder(@NonNull holder: VH, position: Int)

Called by RecyclerView to display the data at the specified position.

open Unit
onBindViewHolder(@NonNull holder: VH, position: Int, @NonNull payloads: MutableList<Any!>)

Called by RecyclerView to display the data at the specified position.

abstract VH
onCreateViewHolder(@NonNull parent: ViewGroup, viewType: Int)

Called when RecyclerView needs a new ViewHolder of the given type to represent an item.

open Unit
onDetachedFromRecyclerView(@NonNull recyclerView: RecyclerView)

Called by RecyclerView when it stops observing this Adapter.

open Boolean
onFailedToRecycleView(@NonNull holder: VH)

Called by the RecyclerView if a ViewHolder created by this Adapter cannot be recycled due to its transient state.

open Unit
onViewAttachedToWindow(@NonNull holder: VH)

Called when a view created by this adapter has been attached to a window.

open Unit
onViewDetachedFromWindow(@NonNull holder: VH)

Called when a view created by this adapter has been detached from its window.

open Unit
onViewRecycled(@NonNull holder: VH)

Called when a view created by this adapter has been recycled.

open Unit

Register a new observer to listen for data changes.

open Unit
setHasStableIds(hasStableIds: Boolean)

Indicates whether each item in the data set can be represented with a unique identifier of type java.lang.Long.

open Unit

Sets the state restoration strategy for the Adapter.

open Unit

Unregister an observer currently listening for data changes.

Public constructors

<init>

Adapter()

Base class for an Adapter

Adapters provide a binding from an app-specific data set to views that are displayed within a RecyclerView.

Public methods

bindViewHolder

fun bindViewHolder(
    @NonNull holder: VH,