‫Welcome back.
‫Now let's continue with the adapter class.
‫And here we have an error.
‫We need to implement the members.
‫We need to implement three methods.
‫Because this class my adapter class extends from RecyclerView dot adapter class.
‫So hover the mouse or click on this red bulb.
‫Implement the members.
‫We have three methods to implement in this class.
‫Three crucial methods are involved in the process of creating and updating views within the RecyclerView.
‫These methods are on creating view holder, on bind View holder and get item count.
‫Click okay and here you are implementing them inside this class called my adapter.
‫Let's start with the first method on Create View holder.
‫This method is called by the RecyclerView when it needs a new view holder instance.
‫It's responsible for inflating the layout for a single item and returning a new view holder that holds
‫references to the views within that item.
‫The view group parameter is the parent view that the new view will be attached to after it's bound to
‫its data.
‫The int parameter represents the view type.
‫In many cases, you might have only one type of a view, so you can ignore this parameter or use it
‫to distinguish between different view types.
‫Inside this Oncreate Viewholder method, I'll start with val v equals to layout inflator dot from parent
‫dot context.
‫And here I need to pass the context of the parent and inflate method.
‫I need to pass the layout that we created, item layout and the parent and the third parameter is false.
‫So what does this code mean?
‫This code is a common pattern for inflating layout for displaying inflating means displaying for inflating
‫layout for a single item in RecyclerView within the Oncreate view holder.
‫Method of the RecyclerView adapter class layout inflator dot from parent context layout inflator is
‫a class in Android used to instantiate layout XML files into their corresponding view objects.
‫Here you obtain layout inflator instance from the parent dot context, inflate method used to specify
‫the layout to be inflated, and the view group.
‫So r dot layout.
‫Dot item layout.
‫This is the resource ID of the layout XML file that you want to display and inflate.
‫For each item in the recycler view, it could be a layout file specifying the visual structure for a
‫single item in the list, and this is the case that we have only one image view and two text views,
‫and this layout acts as a template for each item in the recycler view to be displayed.
‫Parent the view group into which the inflated layout will be attached.
‫In the context of Recycler View, it's the parent view group to which the view holder is being attached.
‫This is often the recycler view itself, so there is no need to change the parent.
‫False.
‫This is the parameter indicating whether the inflated view should be attached to the parent immediately.
‫Setting it to false means that the inflated view is returned by not attached yet.
‫The recycler view will handle attaching it when needed, so don't change these parameters.
‫The parent and false when using the recycler view only change this when calling your custom layout.
‫That will be the template for each item in the recycler.
‫View.
‫The valve.
‫This is the line declares a variable named V to hold the reference to the inflated view.
‫The type of V is inferred based on the result of the inflate operation, which is likely a view or subclass
‫of view, and this case it's a view because I used layout inflator and inflate method that returns a
‫view.
‫The overall purpose of this line is to create a new view by inflating the specified layout file.
‫R dot layout.
‫Dot item layout.
‫This is the layout file for a single item in the recycler view.
‫This view will.
‫Will later be used to create a Viewholder instance in the Oncreate Viewholder method of the RecyclerView
‫adapter class.
‫I'll return my Viewholder and here I need to pass this view.
‫This is how we configure the Oncreate Viewholder method in RecyclerView.