July 2018
Intermediate to advanced
266 pages
7h 11m
English
The idea behind RecyclerView is that the expensive process of creating views will be avoided as much as possible. Instead, a small set of views is created and they are reused—no space either side—check throughout hence the name RecyclerView—to display information as the user scrolls.
For this to work, we are expected to have a ViewHolder, which is an object that holds the layout elements of the view so that they can be reused later – recycling them. Let's create a ViewHolder inside the adapter, based on the layout that we defined for each item:
class ArticleAdapter { private val articles: MutableList<Article> = mutableListOf() class ViewHolder( val layout: LinearLayout, val feed: TextView, val title: TextView, val summary: ...
Read now
Unlock full access