‫Welcome back.
‫In this video we're going to learn about view holders.
‫We created this inner class.
‫My view holder inner is a keyword used to declare inner classes.
‫Inner classes can access the members including properties and methods of the outer class, in this case
‫the sports adapter.
‫The constructor of my view holder takes a single parameter item view, which a type view which is a
‫reference to the view representing an individual item in the recycler view.
‫This view is typically inflated from the item layout and this class.
‫My view holder will act as a view holder since we extended from the recycler view dot the view holder
‫class.
‫Again, guys, view holder used to hold the references to the views within each item.
‫In the recycler view, you will define and initialize the views.
‫Example text views image views within the item layout in this class.
‫This is usually done in the init block or directly in the constructor.
‫And this is what I'm going to do next.
‫Here I'll start with var sports image.
‫It's of type image view and var sports name.
‫It's of type text view and Alt+ enter to import the classes.
‫And here in the init block I need to initialize these widgets.
‫So sports image equals to item view.
‫I'm referring for this view dot find view by id or id dot image view card and the sports name equals
‫to item view dot find view by id added dot.
‫Go back.
‫It's named as text view.
‫I'm referencing these two and initializing these widgets that I declared them into the card item layout
‫this image view and this text view.
‫Okay, so this is how we use the view holders in Android.