‫Hello, my friends.
‫After we succeeded in adding the data binding to this journal underscore row cardview layout.
‫Now let's use this data binding object in our recycler adapter.
‫At first let me change this code from this to using the binding object.
‫So despite using this layout inflator, I'm going to use the binding object and set the layout inflator
‫to our layout.
‫So.
‫Journal.
‫Rho binding dot inflate.
‫And here I will use layout inflator dot from parent dot context.
‫And the second parameter is.
‫Parent.
‫The third parameter is false.
‫I'm passing the view group as the second parameter exactly like this.
‫And the third parameter attached to the root is equal to false.
‫Okay.
‫I will return my viewholder here.
‫I will pass the binding.
‫All.
‫So I will change this.
‫My viewholder I will remove this also.
‫I will remove this.
‫And of course this.
‫So I will change it.
‫Alt+ enter to add parameter to constructor of type binding.
‫Refractor.
‫You can see that we have added an object of type binding to the parameter.
‫And here I need to add constructor parameter of item view.
‫So.
‫This is our class.
‫My view holder.
‫Later on we will.
‫Add some codes to it.
‫So this is the Oncreate view holder.
‫And you can see there is an error.
‫No value passed for the parameter item view.
‫Since I'm using the data binding, I don't need the item view anymore, so I will get rid from this.
‫And here the viewholder.
‫I will pass binding dot route as the item view.
‫You can see it.
‫Okay.
‫Now let's continue with the on bind viewholder.
‫We don't need any of these variables and and setting find view by ID and getting the views by ID and
‫set them to the correct text.
‫It's only using the data binding.
‫We need to use val journal equal to journal list.
‫And dot position or get the position here.
‫And here holder dot find.
‫This holder.
‫I don't need it as a view holder.
‫I need to pass data binding object of type.
‫Journal.
‫Rho binding.
‫So here.
‫Find.
‫The Journal.
‫What can use the my viewholder and I can call the method bind.
‫I will add bind to the my viewholder.
‫So I will create a new function called bind in order to attach the binding for this this item that we
‫passed it.
‫Of type journal rho binding.
‫With a journal.
‫The modal variable.
‫So I will select this journal and.
‫Binding dot.
‫Or this?
‫Dot journal equal to this journal and I need to change this to var.
‫Okay.
‫So I will pass for the my viewholder parameter binding and I'm using from this binding the journal and
‫set it to this journal.
‫Parameter of the bind.
‫Method.
‫Okay.
‫This is all we need to do with the unbind viewholder method.
‫The get item count.
‫It's very simple method.
‫It's just returning the size of our list.
‫So how many items I need to do to display?
‫I will set it like this equal to.
‫Last.
‫Journal list.
‫Dot size.
‫Okay.
‫And this way we created the recycler adapter using the binding data binding.
‫And you can see it's very simple and it's easy then before.