Welcome back.
In the last video, we prepared this a little circle here, and that will be a list item within our
list that should be displayed in a horizontal fashion.
So in order to display it in a list, what we will need to do is we need to use a recycler of you,
but the recycler of you needs to have an adapter in order to know what it should display.
So we need to create our recycle of you for this.
So either we use the default one, but the problem is it's not going to give us what we need or we create
our own.
So I'm going to show you how to create your very own recycler view adapter so we can create a new cottoning
class.
And we're going to call this one exercise.
Statis adapter.
And this adapter should inherit from recycler of you thought adapter.
And this adaptor, it needs to have a view, holder, that we give it as a type.
All right.
So what type of adapter do we want to have?
Well, we want to have the type of adapter that holds views.
And what kind of use should it hold?
Well, in our case, it should hold the view that we created, which is this little circular thingy
here, this circle here.
So instead of passing, it's a default view holder, I will create my very own view.
Holder So I'm going to create a new class here and I'm going to create a nested class.
So it's going to be within our exercise status class.
So exercise studies adapter to be more precise.
And here I'm just going to call this one view holder.
Which will require a view.
Of type you and it's going to you.
Inherit from the cycle of you, you holder.
And this one also, of course, needs a view now, we, of course, need to import view.
So let's do that real quick and now I can go ahead and create a new variable.
I'm going to call this one TV item being my view, that TV item.
OK, so the view Holder describes an item view and metadata about its place within the recycler of U.
All right, so that's what we want to do with this withholder We want it to describe an item.
You all right?
In this case, it's just going to be the TV item.
What is the TV item?
Well, it's this little circle here because that's how we call it Soheir Android ID, TV item.
That's the name of it.
All right, so the next thing is we can pass it to this recycler, view the view hole that we created.
So I'm just going to say exercise status adapter dot view holder.
And here we need to have the brackets now, it, of course, needs to have certain information when
we now go ahead and create this exercise status adapter so you can see it needs to implement some members
a bunch of functions.
But before we do that, we also need to comply to the structure of an recycle U.
Adapter.
And what we need is the items that we want to display, which is an array list of exercise model in
our case and the context.
Which is a type context.
All right, so in which screen, so to say, should this exercise status add up to be displayed?
All right.
So now we need to import context for this as well.
And now we can go ahead and implement the members that are missing.
So the three so uncreate view Holder, get out and count and unbind view holder, so uncreate view Holder
will be called, wants to view Holder is created.
So once the screen is displayed, so to speak, item count will show us the amount of items that we
have in our list.
So in our list view, or to be more precise, in our recycle of you, which is just an extended version
of our list view and then the unbind view holder binds each item in the Israelis to a view.
So it's called when the recycler view needs a new.
You holder of the give and type.
All right, so let's go ahead and implement those and actually only implemented one of them because
I clicked on it.
But you can access all of them or mark all of them in press.
OK, so you can see we have unbind view Holder on creative you holder and get item count here and none
of them are implemented, so we need to implement them ourselves.
So let's start with uncreate view holder.
So this one, what does Uncreate View Holder do?
Well, as I said, it's called when the View holders created, but it inflates the item use, which
is designed in the XML layout file.
So in our case, it's going to display the little view that we created this little circle.
All right.
So what we need to do here is we need to return something.
So, as you can see, it expects a return value of a few holder.
So we need to return to the view holder and we're going to return our own view holder that we created.
So this class that we have here.
And you Holder.
We'll need a layout inflator from context.
Thoughts and.
And what do we want to inflate?
Well, our our to lay out that item, exercise status and what's the parent of it?
Well.
Just the parent.
And then a patch to root.
I'm just going to set false, so I don't want to attach it to any root.
OK, so this is our view, Holder, and I'm going to put this on the next line so it's a little more
readable.
So we have this return view holder.
It needs a layout inflator from inflate.
And you can see let's see what inflate Paz's back.
It returns a view and you can see it's a Java class here.
So layout inflators, a Java class.
But we can easily use it in here.
All right, so.
If you want to know more about it and about the resources you can see inflate a new view hierarchy from
the specified XHTML source throws enfilade exception if there is an error.
OK, so basically it just helps us to display something in our list.
All right, it's a lot more complicated than it could be, but in the end, that's what it does.
Then we need to check out our unbind view holder.
So what do we want to do in there?
Well, we want to assign the right text to every single one of those circles, because if we don't do
that, each circle will, for example, just have one in there or they will just be empty.
But we want to assign a value to each of them.
And in order to assign a value, we first of all need to create a model or I'm going to call this model,
which is going to be my exercise model and I'm just going to.
Used the position of the items that we looking at.
So what are the items?
Well, it's the items that are passed to us, so this array list of exercise modalities passed to us.
So which pretty much means that once we create an exercise status adapter will need to pass some items.
In our case, it's going to be the 12 exercises.
Right, because we need to pass this array list of exercise model.
And if you can remember, we created such a list, which we call default list or something like that.
All right.
And now we can use these items and then we can look at their position and that's where it comes into
play.
So which position are they at?
So, for example, the very first entry of the list is going to be the one.
The second entry will be the two and so forth.
So now we can go ahead.
And.
Get our holder.
And then excessive item, excessive text and said it's text to model, get I.D. to string.
So now you can finally see what we need our ID for because.
You maybe don't remember, but in our model exercise model, we had this thing called ID, which she
had never used before.
And the idea, if we look at our concerns for our jumping Jack was one for our walls.
It was to push up three and so forth.
All right, so going back to our.
Studies adapter, now we set the text of our TV item.
As being the.
Idea of the element that we're currently in the position of so that we're currently looking at, so
if we are and the first entry, it's going to be the idea of the jumping jacks, which is one.
And then we said that to our TV item text, so what is this holder?
Well, it's the holder that is past the hour on Point View Holder, and it consists of Taibu Holder
and.
There we have this TV item, so we pass our.
You're older or a class of type, your older and in there we have this TV item, which in the end is
really just our TV item.
So it all is interconnected, as you can see, but it's not something super intuitive, so to say.
All right, so then there's one thing missing, and that is our item count, because we haven't implemented
that.
So the item count will display the amount of items or it needs to return the amount of items that we
have in our.
Recycle of you, so in the whole list, you so it's just going to return.
Items that size.
So however many items we have in our recycle of you, that's how many it's going to return as get to
item count.
So by accessing this, we will know how many items we need to display.
All right.
So now the only thing that's left is to use all of that because we prepared the status adapter, we
prepared the item, but now we need to put it into our exercise activity in order to see it.
So that's what we're going to do in the next video.
So see you there.