https://developer.android.com/develop/ui/views/layout/recyclerview

RecyclerView makes it easy to efficiently display large sets of data. You supply the data and define how each item looks, and the RecyclerView library dynamically creates the elements when they're needed.

As the name implies, RecyclerView recycles those individual elements. When an item scrolls off the screen, RecyclerView doesn't destroy its view. Instead, RecyclerView reuses the view for new items that have scrolled onscreen. RecyclerView improves performance and your app's responsiveness, and it reduces power consumption.

Note: RecyclerView is the name of both the class and the library that contains it. On this page, RecyclerView in code font always means the class in the RecyclerView library.

Key classes

Several classes work together to build your dynamic list.

You can see how all the pieces fit together in the RecyclerView sample app (Kotlin) or RecyclerView sample app (Java).

Steps for implementing your RecyclerView

If you're going to use RecyclerView, there are a few things you need to do. They are explained in detail in the following sections.

  1. Decide how the list or grid looks. Ordinarily, you can use one of the RecyclerView library's standard layout managers.
  2. Design how each element in the list looks and behaves. Based on this design, extend the ViewHolder class. Your version of ViewHolder provides all the functionality for your list items. Your view holder is a wrapper around a View, and that view is managed by RecyclerView.
  3. Define the Adapter that associates your data with the ViewHolder views.

There are also advanced customization options that let you tailor your RecyclerView to your exact needs.

Plan your layout

The items in your RecyclerView are arranged by a LayoutManager class. The RecyclerView library provides three layout managers, which handle the most common layout situations: