Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

RecyclerListener

interface RecyclerListener
androidx.recyclerview.widget.RecyclerView.RecyclerListener

A RecyclerListener can be set on a RecyclerView to receive messages whenever a view is recycled.

Summary

Public methods

abstract Unit

This method is called whenever the view in the ViewHolder is recycled.

Public methods

onViewRecycled

abstract fun onViewRecycled(@NonNull holder: RecyclerView.ViewHolder): Unit

This method is called whenever the view in the ViewHolder is recycled. RecyclerView calls this method right before clearing ViewHolder's internal data and sending it to RecycledViewPool. This way, if ViewHolder was holding valid information before being recycled, you can call ViewHolder#getAdapterPosition() to get its adapter position.

Parameters
holder RecyclerView.ViewHolder: The ViewHolder containing the view that was recycled