Design + Code an Android App from Scratch
Scrounge up some loose change to become a pro member, or login to your account to view this lesson.
Alright, join now. Or login to your account if you're already a pro member.This video shows you how to implement RecyclerView.Adapter class. In the first step, we create a class that extends from RecyclerView.Adapter. In the second step, create a class that extends from the RecyclerView.ViewHolder that specifies the layout for a single item inside the RecyclerView. Next we implement the onCreateViewHolder, the onBindViewHolder and getItemCount methods inside the RecyclerView.Adapter subclass. We get a Java object that represents the XML layout of a single item which we created in the previous video and supply this Java View object to the subclass of the RecyclerView.ViewHolder. The idea behind using a ViewHolder is to avoid calling findViewById for each row in the RecyclerView. The onBindViewHolder lets you put data inside each row which the user eventually sees on the screen.