This basically caches views objects which allows us to reuse/recycle views. ViewHolder: Contains reference to the view objects of the item.The two of them can be considered sort of a single unit. Adapter: Provides RecyclerView with new views(list items) when needed and binds data to the new and recycled views.RecyclerView: The primary view where the list is displayed. ![]() The idea here is to not generate views for all 100 items and only generate enough to cover the screen and a few extra and keep using them over and over again.Ī high level overview of how everything is connected For example if we have 100 items, only 10 list items are used and displayed out of which 7 are being displayed and 3 are being used for smooth scrolling. It does a lot of optimizations, but mainly it recycles views in the list as the name suggests.It allows us to display our list vertically, horizontally, in a grid or in our own custom layout.It gives us ability to use complex layout for items in the list, there is only so you can do with appending in a TextView.Why are we using RecyclerView and what problem does it solve for us? You can get the code here to follow along. ![]() Up till now we have created an app that can query the github API, parse the JSON and display names and description in a single TextView. If you want to learn how to do it in Kotlin go to How to create a RecyclerView with custom Adapter in Kotlin. In this article I go over how to create a RecyclerView in Java. Tags: Android, Android Basics, Github Repository App, RecyclerView, Avin's Blog Android Basics: RecyclerView - I, creating a RecyclerView with custom Adapter
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |