RecyclerView
is an element in a layout that binds to other elements to reuse existing views rather than removing and creating them as displayed elements change.LinearLayoutManager
: 1-d list
GridLayoutManager
: 2-d grid with standardized dimensions depending on arrangement axis
StaggeredLayoutManager
: 2-d offset view without standardized dimensions
The key classes used with RecyclerView are ViewHolder
and Adapter
. Overriding several methods is necessary for proper functionality:
onCreateViewHolder()
: used for creation of views
onBindViewHolder()
: used for replacing views’ contents in the layout
getItemCount()
: used for assessing data set sizes