What is the function of RecyclerView
in an Android application?
What is the function of RecyclerView
in an Android application?
RecyclerView
came to replace both ListView
and GridView
(including entities supporting both).
RecyclerView
is much more efficient than the two previous implementations, even using a setting of ViewHolder
almost equal (we can not define optimization only in the ViewHolder
aspect). One of the great advantages of this is the flexibility to be able to change from LayoutManager
without having to implement a code truck just to have tiles or cards in our list.
As with ListView
and GridView
, RecyclerView
needs extra entities to work, in this case we have LayoutManager
(in the video I used LinearLayoutManager
) that is responsible for the redenrization of View
of each item on the device.
We have Adapter
which is responsible for binding data from the set passed to it to View
(which will be the view of each item of RecyclerView
) and then send that View
to LayoutManager
.
And, finally, we have the ViewHolder
that is responsible for caching the View
's created in the onCreateViewHolder()
method to later reuse them by optimizing the work with RecyclerView
.
Video: link