Welcome back.
And this video we are going to start with is BMI calculator functionality.
And as you can see, there is a little button here currently centered, but later on, we will have
multiple buttons here next to each other for now, just two.
But still, you could extend it any time.
But as you can see here, we have this BMI button, and once we click on it, this window opens up.
And here we will then later do the calculations of the BMI.
So we will need to set up a lot of things in here.
And that's what we're going to do later on.
But for now, let's just start with what we can see here, so we need this.
But in here at the bottom bottom, the BMI calculator and what I need to do, of course, is to adjust
my activity, Maine, and that will be inside of my project here, resources, layout, activity, Maine,
because I need to add another button here at the bottom.
Right.
So in order to do so, I'm just going to add a linear layout just underneath the linear layout that
we had in here.
So I'm going to put it in here.
Now, this linear layout is going to be just underneath the linear layout where we had our start, let's
look at it, we can see that this is how it's going to look.
So we create this whole area here.
This is my linear layout here at the bottom, and it takes the whole available space towards the top
and the right.
So let's look at it.
We can see that it's this one here.
It matches the parent in with and the parent in height.
So it takes the whole space.
It's centered and the orientation is vertical.
So things will be on top of each other.
And then there I also have another linear layout, which is for now my BMI linear layout, which contains
the text view, which is says BMI, and it has a background which is our item, circular color accent.
Background, OK, so it's this file that we created, which is a shape that is oval and has a solid
background color, which is green.
So it's just a green circle and that's exactly what we have there.
So you can see here at the left hand side, it's a green circle.
That's this big circle.
On top of that, we have a text.
So we have this TextView saying by the text, color is white, the text size is 22, and it only wraps
its content.
So it only takes as much space as it really requires the Texas head to Bolt.
And underneath that, I have another text view, which is then just saying, call you later.
All right.
I have some margin towards the top, the height and with our content.
And I have this green color as the text size.
So you can see here, this is this calculator text that we have here at the bottom.
All right, the next thing we need to do is to set up another activity, because I want this to open
up and a different activity.
So let's go ahead and create a new activity and it's going to be an empty activity.
I'm going to call this one VMI activity.
And then instead of this being my activity, well, the first thing we need to look at is how we design
it and I'm going to design it the same way I did for the other one.
So I'm also going to set the orientation to portrait and the theme to be in a combat light action.
No action bar and here I'm going to shorten the coat.
OK, so that is step number two and three.
Now, let's go ahead to the next step, which is to create a activity BMI layout.
So we have this activity on the scoreboard, on the score and on the score.
So maybe it's not the best name.
So you could change that if you want to on the score BMI.
And I'm just going to leave it for now.
I get this and what I want to add in here.
So what I want to put in there is a toolbar and I'm going to make this whole thing, this constraint
layout, a relative layout.
So I want to put stuff relatively there.
So I'm going to use a relative layout here.
And as you can see now, the arrow disappeared, so now it works to have a toolbar here.
As you can see, the orientation should be vertical.
Because stuff should be on top of each other.
Next, I want to set up the BMI activity itself.
So inside of this uncreate method, I'm going to prepare the action bar.
So let's create a support action bar here, tool bar on the score, BMI on the score activity.
And then I'm going to create an action bar.
So.
Well, action bar.
Which will the Support Action Bar?
And if the bar isn't empty, so if it exists, then I want to.
Set something up, so I'm going to say.
The action bar should be set to set display home has enabled.
To true.
This will set the back button, so now we will have a back button on this action bar and then I set
the title.
So I want to have the title of.
Calculate BMI.
All right, so this sets the title of the action bar, and then the next thing I want to do is to add
an on press event once we click on the back button.
So Toolbar EMI activity should be set navigation on Click Listener and it's going to call on back press.
So the same functionality that you would expect when you press the button on your phone.
OK, not just on the top left on the navigation bar, watches the back button on your phone.
It's going to do the same thing now here.
This site navigation is called on the toolbar activity, if you were wondering, that's this toolbar
that I created.
So it has this idea called toolbar PMI activity.
That's how I can access it.
OK, now there's one thing left, of course, and that is to get to this activity.
And in order to get there, we, of course, need to add something in our main activity.
So if we look at our.
Main activity we saw earlier in our.
Layouts that we added this little.
Button, which we called.
LLB, so it's not the button, it's a linear layout, but it's going to behave like a button.
So I'm just going to say, once we click on LLB, my then we should go to the beach, my activity.
OK, so let's go back to our main activity and do that.
And I'll be am I?
Set on Click Listener.
And in there, I'm just going to create the new intent, so I'm going to do the same thing as we had
here, only that now the class that we want to go to is our BMI activity, OK?
And that should already be it.
That's enough for us to test the application.
OK, so there we are.
Let's press on BMI and we can see we get to this other screen, calculate BMI is the title, which is
exactly what I wanted.
And then, of course, we need to create the design here.
And that will be a little more complicated because we need to take two things into consideration.
The calculation is done differently for the US as it is done or than it is done for other countries
which use the metric system.
So when you weigh yourself in pounds and you measure your height and feet and and in inches, then you
need another calculation, also another UI then when using the metric system and that's what we will
need to set up.
So see you in the next video.