Welcome back.
And this video, we are going to add the history button, so once you click on it, you can see we go
to the history activity.
For now, it's empty.
But later on, it will be a recycled view, which contains all of the finished exercises that we had.
So we also need to store those finished exercises at one point.
But that's what we're going to do later.
For now, we just need to get to the point where we have this.
You are.
So that's the challenge for this video.
You can try to build that yourself.
You will need to have this image.
You can find it inside of the project that you can download and then you just go ahead.
Of course, this year is a linear layout where things are next to each other, so where the UI elements
here are next to each other.
So it has to be in a horizontal perspective or orientation.
And then, of course, this year should always be important.
So this activity should always be portrait mode.
And yeah, that's pretty much going to be it for now.
So you just need to create the intent.
You need to set the title here to history and basically that's it.
So you can try to build that yourself.
Otherwise, of course, just follow along with the video.
All right.
So let's get started.
The first thing we need to do is to add a little icon on our page, which is our main activities.
So let's go to the activity main XML.
Here and there, we need to add a button here at the bottom.
Well, the thing is currently we just have this linear layout, which.
Contains our.
Button here, which just this BMI button, right, but we need the same structure once again, and that
should be inside another linear layout.
Because you know how to build linear layouts, I'm just going to pace the code in here.
And then we will look at everything, OK, so I pasted the code and here it starts here where we finished
off with our start.
So, yeah, this is the text you start, which is this icon that we had there.
Right.
So this linear layout which contains our start again can so is this one here.
So underneath that's where this linear layout starts.
We can see that I said the orientation to horizontal gravity centered margin top 30 and I'm using base
line aligned.
And what base line A thus is what you can find here.
So we have an example.
If base line a line is set to force, that's the result.
We get a baseline, a line is set to true, then that's the result that we get.
Because as you can see now, the text has two lines, so to speak, and now the baseline is aligned
accordingly, but that's not necessarily what you want.
So sometimes you just don't want to set this to true.
That's why we said it directed to false.
Right.
We've used it before, but I didn't explain it there.
But now you can see what it's used for.
All right.
Then we have this other linear layout and another linear layout.
So this very Ortolani allowed is the overall linear layout where the two buttons should be next to each
other.
But then we have another linear layout, which is this BMI button and then the linear layout, which
contains the BMI button and also the calculator text view.
So this is just a text for BMI.
And then we have another text you, which is this calculator, so.
This button itself is a linear layout, and then this calculated text is in another linear level which
surrounds it, and then there's another linear layout which puts those two buttons next to each other.
So that's why we need so many different linear layouts.
So basically, I just pasted the old linear layout we had before inside of it because that's what we
already had built before.
Right.
And now I have another linear layout surrounding it in which I'm just saying, OK, I want to put stuff
next to each other.
So that's why I'm using this horizontal orientation.
And then, of course, inside this ultra linear lab, we have another one, which is going to be our
calendar button and it has the same structure.
So we have a linear layout where things are vertically oriented.
So our UI elements are vertically oriented.
And then we have this linear layout, which is, first of all, the icon itself.
So this little icon button and then the TextView, which is underneath it, which is.
This history, TextView, all right.
And that's pretty much it, so, of course, we need to have this icy calendar image and of course,
you can download it from the project, as we've done before.
So just download the image and then drag it or paste it into your resources folder and to this drawable
folder.
Now, let's see if this guy already works.
And we are so of course, it doesn't do anything yet because we can't click on it, we haven't implemented
any functionality.
But overall, you can see that this is our history.
I can hear.
All right, now let's create the activity so the history activity.
And I'm going to create a new activity, which is going to be an empty activity, and I'm going to call
it.
History activity.
Once it's done, I go to the manifest because I also want to have the same rules apply.
So the screen orientation and the theme should be the same as with all of the other activities.
So I'm just going to add that in here across the screen, orientation is going to complain, but I'm
just going to leave it as is.
And this additional hero is not necessary, as well as the keyword here, so what's important is that
the activity is closing correctly.
All right, so that's our manifest.
The next thing we need to set up is the history.
XML file, because in here we don't have anything right, but I'm just going to use a linear layout
here instead of this constraint layout, so linear layout and inside of this linear layout, I want
to have a toolbar and I want to use the same kind of toolbar that I've used in other XML files before.
So I'm just going to open up the activity, BMI, XML file, and I'm going to copy the toolbar from
there, so let's add that in here as well.
Of course, I'm going to give it a different name, so I'm going to call this one toolbar history activity.
And then inside of the history activity, I'm going to add the same code that we had here where we set
the bar, so set Support Action Bar, as well as adding the toolbar functionality.
So I'm just going to copy this code here as well.
So I'm going to paste it inside of my uncreate.
And I don't need to import this element because I'm not going to use that one, because I'm just going
to use toolbar history activity.
And here, of course, it's also the toolbar history activity that we need to set for the navigation
and click listener.
And the action bar title should not be calculate PMI, but it should be history.
All right, now we only need to intent, which leads us to get here, so let's go to our main activity.
And there we had this intent, which led us to the exercise activity to be my activity and so forth,
so we're going to do the same thing here as well.
And it's going to be El Al history.
And I'm going to use pretty much the same code that we did here as well, so set on Click Listener,
but of course it's the history activity that we want to move over to.
OK.
And that's pretty much it.
So there was nothing new here, nothing too fancy.
We really use the same structures that we have used before.
That's why I really went over this very quickly.
If anything of that didn't make sense to you, then check out all the videos on the topic that didn't
make sense to you, OK, because basically it's really the same thing that we've done before multiple
times already.
So pressing on this report and you can see I get to this new activity which says history.
When I press on the button, I get back to my start activity.
All right.
So now we have prepared everything for our history site.
So for our history activity, of course, we now need to create a recycler view, but we also need to
look into storing data with SQLite.
So let's do that and see you in the next video.