I'm back and this video, we're going to add this history button here at the bottom, as well as set
up the history activity with an action bar here at the top that allows us to go back, but nothing else
for now.
And this is something you should be able to implement yourself.
I would recommend that you try this and if you are done, then check out the video or just jump to the
next one.
OK, so the first thing that we're going to require is going to be a new activity, and I'm going to
use an empty activity here that I'm going to call history activity.
And we're going to let it generate the layout file for us, the layout file.
Will be very simple.
At least for now, we will have a toolbar inside of the constraint layout, so this toolbar will have
an idea of toolbar history activity.
It's with will be apparent.
Its height will be action bar size and the background will be white.
So similar to the other activities where we had the same thing.
So here in the BMI activity we also had at the very top this toolbar and we're doing the same thing
now for our history activity.
Now inside of the history activity, I'm going to start off by creating my binding object.
OK, so binding activity, history binding, which was another bowl and I'm going to assign null to
it.
Then in the on create method, I'm making sure that my binding object is initialized.
So binding will be activity history binding that inflate with the layout inflator as the parameter and
then as the content view, we are using our binding dot root object.
OK, so binding dot root or binding object with the root property.
And then we are using the said support action bar stuff like we had it here.
So let's implement the same thing.
Let's copy it from our BMI activity and put it in here, even though we of course, need to change the
names here.
So there will be the toolbar history activity.
And the title should be.
How did the college here history?
OK.
So let me change that to be his story makes it OK.
That's our history activity for now.
Of course, we want to display some more information here.
We're going to use a recycle view displaying all of the exercises that we have done in the past.
And now we need to get there at one point, right?
So how can we get there?
Well, from our main activity, we will need to add, first of all, this little icon here at the bottom,
just next to the calculator.
So let's do that.
Let's go over to our activity.
Main Axiom L.
And then at the very bottom, basically do the same thing that we have done before, so we can copy
this frame layout with the text you and we can duplicate it and then make a couple of changes to it.
So first of all, this other frame layout will be not the BMI frame layout, but the history of frame
layout.
All right, then we need to make sure that it's at the bottom of the parent at the end of the parent
and at the start of the parent, start to not start of the parent, but this time end of the parents.
So we want that to be on the right hand side and its top should be to the bottom of the NFL start.
So it should be underneath our frame layout start, which is this frame layout.
Here you can see it's already direct towards the right hand side, but it's not fully done yet.
So let me go back to the activity main coach here.
Then let me add a gravity here, so gravity, which will be centered.
So therefore, I need to have layered gravity first, so lay out gravity.
ProBit said to center, and this is inside of Android layout, gravity.
And it's not a capital C, OK, that should be fine, and now we can use the gravity center as well,
like so?
Then I'm using my image view, which does not have a text BMI, but instead it should use an image.
OK, so I'm going to change that using a source.
So SIRC Android colon as our see which would be at.
And then I need to import Strobl.
I'm going to use my I.C. calendar here.
You can, however, use your own images if you want to.
So let me add that rubble in here.
I see calendar, which will be.
This trouble.
OK, so I'm going to use this I see calendar image for my text you and actually make it an image you
like, so because it shouldn't be a text to you.
The text you can be underneath, which should say history, but this is going to actually be an image
of you instead.
OK, so we have the width and because we're using an image here and we use 50 dpi for its height and
its width and the layout, gravity should be centered as well.
We will not need a text size, text color.
Neither of those things are going to be required and that should do the trick for the image view.
And now on the knife, we have this text view which should not say calculator, but it should say history.
The text can stay green.
It's going to be, however, at the end of our official history.
OK, at the start of.
The whole history as well.
And at the top to bottom of AFL history.
So now we just need to make sure that our frame layout is positioned next to the.
BMI.
So I have top to bottom of start, that's fine, but start to end off, that's the one that I need to
change.
So at I.D. and it should be at the end of BMI.
Let me see if that's the case.
OK, now it is.
You see, now it's at the end of this BMI, so it comes just after it.
But there's the BMI frame layout, including the text.
You are not at the left hand side yet.
So let's first make sure that end is at the start of the IPL history.
Then the top to bottom, that's fine.
And the sheer bottom to bottom of parent, that should be fine.
Let me see.
Yep, that's looking a lot better.
The calculator, however, is not being positioned with this.
TextView has to be underneath the eye.
So let me change that as well.
And that is this text you, which is underneath the frame layout.
So we need to make sure that its end is end of old BMI.
The start is to start off, have a BMI, and now let's check it out.
Yeah.
So you see if it's at the start and the end of the AFL, BMI just positions it underneath it.
So if it's at the bottom of itself, so it's like we're saying, OK, it should be at the left hand
side of it, it should be at the right hand side of it and it should be underneath it.
And that's what it creates this behaviour where it's just underneath.
OK, and now we just need to make sure that we can click on it.
So instead of the main activity, let's add an oncolytic in for our AFL history, which will move us
to the history activity.
OK, so here I just copy this code and change the name of the item that we're clicking on and change
the class we're going to with the intent.
So now let's see if we can actually go over and if we see the history being displayed properly on our
UI.
OK, so there, let click on it, and we see we are in the history activity and we can go back with
the back button at the top there.
OK, so that's it for this video and the next one, we're going to first look at how.
The room database works because we want to store data permanently, and that will be done in the next
video, so see you there.