1
00:00:00,760 --> 00:00:06,910
Welcome back in this video, we are going to build the BMI calculator and you can see that's what we

2
00:00:06,910 --> 00:00:11,380
want to get as a result, we have the calculator button and then here you will see the result.

3
00:00:11,830 --> 00:00:19,180
So I'm currently at 72 kilos, 169 in height, and then I can calculate it and you can see I'm overweight

4
00:00:19,180 --> 00:00:20,100
by just a little.

5
00:00:20,110 --> 00:00:25,240
So let's say I lose one kilo, then I'm going to be normal.

6
00:00:25,360 --> 00:00:25,720
All right.

7
00:00:25,780 --> 00:00:28,210
So it really depends on when I weigh myself.

8
00:00:28,540 --> 00:00:33,610
And there you see whether I'm in good shape or not, I can try it for yourself.

9
00:00:33,610 --> 00:00:39,100
You will even get a little bit of a motivational sentence or just basically a sentence.

10
00:00:39,100 --> 00:00:42,240
Oops, you really need to take care of yourself.

11
00:00:42,250 --> 00:00:42,670
Work workout?

12
00:00:42,670 --> 00:00:42,970
Maybe.

13
00:00:43,060 --> 00:00:43,420
All right.

14
00:00:43,780 --> 00:00:47,100
So thank you very much for this advice.

15
00:00:47,110 --> 00:00:49,270
Even the workout is not going to be the key.

16
00:00:49,510 --> 00:00:53,110
The key is nutrition, so eating better helps.

17
00:00:53,950 --> 00:00:58,780
And now have let's go over them and built this.

18
00:00:58,990 --> 00:01:00,020
So you see what you need.

19
00:01:00,050 --> 00:01:00,850
You need an added text.

20
00:01:00,860 --> 00:01:01,780
Another added text.

21
00:01:01,780 --> 00:01:07,900
You need a bunch of text views and then just calculate button underneath it.

22
00:01:08,410 --> 00:01:11,320
So yeah, I would recommend you try to build this yourself.

23
00:01:11,320 --> 00:01:17,530
There's really nothing too fancy of maybe one or two things that will be tough along the way, but I

24
00:01:17,530 --> 00:01:22,540
would recommend that you try to build as much as possible yourself at this point and then check out

25
00:01:22,540 --> 00:01:23,300
how I do it.

26
00:01:23,320 --> 00:01:27,970
I'm going to go over the individual points a little bit, even though the UI will be something that

27
00:01:27,970 --> 00:01:33,090
I'm going to mainly copy over, even though we are using all relative layouts.

28
00:01:33,090 --> 00:01:36,730
So I believe it makes sense to look into it a little bit.

29
00:01:36,940 --> 00:01:42,580
So in the last video, I added this orientation in the relative layout that doesn't make any sense.

30
00:01:42,580 --> 00:01:47,110
So let's delete that real quickly because in the relative layout, that doesn't have any effect.

31
00:01:47,440 --> 00:01:50,590
OK, so let's not use it then.

32
00:01:51,680 --> 00:02:02,060
I'm going to have a text input layout with an added text, and how that works is you use a text input

33
00:02:02,450 --> 00:02:07,640
layout like so you can give it the width and height and stuff.

34
00:02:07,640 --> 00:02:12,830
So I'm going to match the parent in terms of width and wrap the content in terms of height.

35
00:02:13,250 --> 00:02:22,400
Then I'm going to give it an idea so that I can access it and I'm going to call this one tile text input

36
00:02:22,400 --> 00:02:26,210
layout metric unit weight.

37
00:02:26,720 --> 00:02:32,210
OK, so if you don't use the metric system, you already can assume that there will be a different system

38
00:02:32,630 --> 00:02:33,320
altogether.

39
00:02:33,740 --> 00:02:37,250
I'm going to add a layout margin of 10 density pixels.

40
00:02:37,640 --> 00:02:44,480
I'm going to use the box stroke color of green, which is our color accent.

41
00:02:45,020 --> 00:02:50,690
So if you look at it, this box has a stroke color, which is this box stroke color property.

42
00:02:52,360 --> 00:02:56,650
And the hint text color will also be this color primary.

43
00:02:56,950 --> 00:02:57,350
OK.

44
00:02:57,640 --> 00:02:59,230
Or actually it was accent, right?

45
00:02:59,230 --> 00:03:00,520
Color accent.

46
00:03:01,890 --> 00:03:06,780
So here, if you look at it, the hint here is this hint text color here at the top.

47
00:03:07,560 --> 00:03:10,710
OK, so that's the green color that I'm using.

48
00:03:11,250 --> 00:03:15,710
And as a style, there are multiple different styles that you can use.

49
00:03:15,720 --> 00:03:23,340
I'm going to use text input layout outline box this one here widget material components text input layout.

50
00:03:23,370 --> 00:03:24,120
Outline Box.

51
00:03:25,910 --> 00:03:26,330
OK.

52
00:03:26,540 --> 00:03:31,490
And actually, this is going to be like this and inside of it, we can then have an app compared added

53
00:03:31,490 --> 00:03:39,320
to text here added text, but have compared to competition, which will work very well on older devices

54
00:03:39,320 --> 00:03:39,710
as well.

55
00:03:40,100 --> 00:03:44,480
So I'm going to match parents and rap content here again for width and height.

56
00:03:45,110 --> 00:03:46,610
I'm going to give this an idea as well.

57
00:03:46,910 --> 00:03:53,060
So let's call this one metric unit weight.

58
00:03:56,010 --> 00:03:59,850
And then as a hint, I'm going to write something like, wait.

59
00:04:01,620 --> 00:04:05,040
In CG kg.

60
00:04:06,850 --> 00:04:13,000
And the input type, so here this is something where you can define what kind of input the user can

61
00:04:13,000 --> 00:04:13,250
give.

62
00:04:13,630 --> 00:04:18,000
And I'm going to make sure that it will only be decimal values or not.

63
00:04:18,070 --> 00:04:19,300
No, that is decimal.

64
00:04:20,019 --> 00:04:22,660
And text size.

65
00:04:23,200 --> 00:04:24,970
Let's use 16 p here.

66
00:04:25,810 --> 00:04:27,820
OK, so this will be my.

67
00:04:28,780 --> 00:04:31,780
Edit text, and now I just need another one.

68
00:04:32,320 --> 00:04:35,580
And let me just copy it from my project.

69
00:04:35,650 --> 00:04:37,300
It will basically be the same thing.

70
00:04:38,310 --> 00:04:44,940
Like so OK, so it will also be a text input layout, and it's going to be called text input layer metric

71
00:04:44,940 --> 00:04:45,910
unit, right?

72
00:04:46,650 --> 00:04:47,070
OK.

73
00:04:47,130 --> 00:04:51,990
And it's going to be below the text input layout metric unit weight.

74
00:04:52,200 --> 00:04:54,660
OK, so that's what the relative layout does.

75
00:04:54,930 --> 00:05:01,650
You can just use the layout below now to upload this ID here, so you can already see that this is what

76
00:05:01,650 --> 00:05:02,010
we get.

77
00:05:02,010 --> 00:05:03,900
We get this top piece, this bottom piece.

78
00:05:04,410 --> 00:05:05,880
And that's exactly what I wanted.

79
00:05:06,300 --> 00:05:07,950
So you can check out the values.

80
00:05:07,950 --> 00:05:10,650
I'm using a margin of 10 density pixels.

81
00:05:10,650 --> 00:05:12,090
Actually, I can get rid of this here.

82
00:05:12,540 --> 00:05:19,260
Then I have a height of rep content width of my parents using the color accents as we did before outlined

83
00:05:19,470 --> 00:05:20,010
again.

84
00:05:20,490 --> 00:05:23,160
And the text to show says height in centimeters.

85
00:05:23,400 --> 00:05:28,230
The type is also no decimal, and it's called eight metric unit height.

86
00:05:29,560 --> 00:05:35,860
I know, and then if we had those text views, OK, so I'm going to use a linear layout to put those

87
00:05:35,860 --> 00:05:43,510
text use just next to each other underneath each other with a predefined setting that I'm going to give

88
00:05:43,510 --> 00:05:44,380
this linear layout.

89
00:05:44,380 --> 00:05:45,370
So let's look over it.

90
00:05:45,650 --> 00:05:48,790
I have this linear layout with a little bit of padding then.

91
00:05:49,900 --> 00:05:52,270
I'm going to say it's underneath the metric unit height.

92
00:05:53,080 --> 00:06:00,190
It has an ID level display beam result would be my result with of my apparent height of rap content

93
00:06:00,610 --> 00:06:03,640
margin towards the top so that it has enough distance.

94
00:06:03,640 --> 00:06:06,310
You see here, maybe twenty five is actually too much.

95
00:06:06,730 --> 00:06:08,440
Sixteen is probably going to be better.

96
00:06:08,770 --> 00:06:12,010
Orientation is going to be vertical, so items are underneath each other.

97
00:06:12,100 --> 00:06:14,500
It's going to be invisible by default.

98
00:06:14,800 --> 00:06:16,990
In the tools, however, it will be visible.

99
00:06:17,530 --> 00:06:21,880
OK, so we want to make sure that we only make it visible.

100
00:06:21,880 --> 00:06:28,780
Once the user has clicked on calculate, then we have the text views that are inside of this linear

101
00:06:28,780 --> 00:06:29,290
layout.

102
00:06:29,440 --> 00:06:35,940
So TV, your BMI, which just shows to your BMI, everything is in caps.

103
00:06:35,980 --> 00:06:38,800
You see here text all caps is said to trousseau.

104
00:06:38,800 --> 00:06:40,060
All letters in.

105
00:06:40,060 --> 00:06:45,010
There are going to be high caps and then text size is 16.

106
00:06:45,430 --> 00:06:50,620
We have another text to you, which is the one that says the actual BMI value.

107
00:06:50,740 --> 00:06:56,590
So by default, in the tools, we're going to set that to 15, even though we don't have it as an actual

108
00:06:56,590 --> 00:06:57,730
text for the application.

109
00:06:58,030 --> 00:07:03,880
I have a little bit of margin towards top for each of the text you so that they are not too close to

110
00:07:03,880 --> 00:07:04,360
each other.

111
00:07:04,900 --> 00:07:06,610
Then we have the overweight text.

112
00:07:08,520 --> 00:07:11,850
Which is this one here, TV bear my type.

113
00:07:12,390 --> 00:07:19,470
And then we have the BMI description, so TBE BMI description, which will show the description of what's

114
00:07:19,470 --> 00:07:20,820
up here, so they're not bold.

115
00:07:20,820 --> 00:07:24,450
Only this one here is going to be bold as textile.

116
00:07:26,010 --> 00:07:29,770
OK, and then we, of course, need to have our button at the very bottom.

117
00:07:29,790 --> 00:07:32,700
OK, so we're going to say this one.

118
00:07:32,820 --> 00:07:37,050
This button will be underneath our linear layout display my results.

119
00:07:37,080 --> 00:07:38,130
So layout below.

120
00:07:38,730 --> 00:07:41,040
It has it the idea of button calculate units.

121
00:07:41,670 --> 00:07:46,350
Then we have our width and height and content layer of gravity towards the bottom.

122
00:07:46,350 --> 00:07:49,170
So you see it's gravitating towards the bottom.

123
00:07:50,580 --> 00:07:57,930
The margin towards top is 35 deep, so quite a distance, that's something you can play around with,

124
00:07:57,930 --> 00:07:58,320
of course.

125
00:07:58,320 --> 00:08:05,490
Texas calculate text color is white, the background color is this green color, our accent color and

126
00:08:05,490 --> 00:08:07,830
the text size is 18 has p.

127
00:08:07,950 --> 00:08:10,320
And again, these are all values you can play around with.

128
00:08:12,920 --> 00:08:15,350
OK, so that is our exit, Mel file.

129
00:08:15,410 --> 00:08:20,450
Now let's go over to the BMI activity where the actual magic is going to happen, and here we have to

130
00:08:20,450 --> 00:08:21,440
do a lot of things.

131
00:08:21,920 --> 00:08:29,540
So first of all, let's start with creating a method that will validate our metric units, so we'll

132
00:08:29,540 --> 00:08:33,409
check whether we have entered something or not.

133
00:08:33,620 --> 00:08:36,370
OK, so here private fun.

134
00:08:37,580 --> 00:08:43,549
Validate metric units and not metric with an A, but with an E.

135
00:08:44,090 --> 00:08:50,720
Metric units will return a Boolean, so it will return either.

136
00:08:51,510 --> 00:08:57,340
It was valid for entry that the user has given, so he has entered something.

137
00:08:57,350 --> 00:08:59,360
So for example, if I enter nothing, please enter.

138
00:08:59,360 --> 00:09:01,180
Valid values will be displayed.

139
00:09:01,190 --> 00:09:07,550
That's what I want to achieve and therefore I'm going to create this his valid variable, which will

140
00:09:07,550 --> 00:09:08,900
be set to true by default.

141
00:09:09,200 --> 00:09:11,810
And then I'm going to get the values from our view binding.

142
00:09:12,230 --> 00:09:18,500
So binding that 80 metric unit white dot text.

143
00:09:19,760 --> 00:09:21,110
And this is a Nullarbor.

144
00:09:21,110 --> 00:09:25,640
So he had a question mark, got text to string is empty.

145
00:09:26,300 --> 00:09:26,690
So.

146
00:09:27,710 --> 00:09:28,400
Is it empty?

147
00:09:28,760 --> 00:09:31,700
If that's the case, then that is valid too false?

148
00:09:32,960 --> 00:09:38,420
OK, because if the user didn't enter anything in there, then I want to say that is valid is false.

149
00:09:39,640 --> 00:09:40,270
Else if.

150
00:09:43,500 --> 00:09:46,620
The same thing here, but for our.

151
00:09:48,260 --> 00:09:58,760
Other property names, so here is that E.T. metric unit height takes to string is empty and then also

152
00:09:59,030 --> 00:10:03,140
is valid is going to be false and then return is valid.

153
00:10:03,170 --> 00:10:07,890
So this is just a way for us to check whether the user has entered something or not.

154
00:10:07,910 --> 00:10:13,550
And we want to do that each time we click on the button, we want to check if the user has done it correctly.

155
00:10:14,030 --> 00:10:19,130
So now let's take care of the calculations and we could create an entire function for that.

156
00:10:19,130 --> 00:10:23,870
But we can also put it just in the create method that will be fine either way.

157
00:10:24,200 --> 00:10:29,360
So here, finding the right button, calculate units.

158
00:10:29,360 --> 00:10:36,470
So we have this button and it's this big green button here and now we have to think what should happen

159
00:10:36,470 --> 00:10:37,670
once we click on this button.

160
00:10:37,970 --> 00:10:41,960
So on one hand, it should take the weight and height and then do a calculation.

161
00:10:42,230 --> 00:10:46,280
It should, of course, check whether they are empty or not, which is why we have this method that

162
00:10:46,910 --> 00:10:48,110
checks for valid entries.

163
00:10:48,710 --> 00:10:53,810
And then based on that, we calculate the BMI and based on the value that we get there, we're going

164
00:10:53,810 --> 00:10:56,360
to fill these text fields here.

165
00:10:56,690 --> 00:10:57,080
OK.

166
00:10:57,440 --> 00:10:59,180
So let's implement all of that.

167
00:10:59,810 --> 00:11:00,200
All right.

168
00:11:00,380 --> 00:11:02,810
So let's add an anklet listener here.

169
00:11:03,320 --> 00:11:05,240
So this is another bill as well.

170
00:11:05,660 --> 00:11:06,710
One click listener.

171
00:11:08,500 --> 00:11:14,800
And we only will do anything if validate metric units will return true.

172
00:11:15,340 --> 00:11:19,270
Otherwise, we don't do anything inside of this method, pretty much so.

173
00:11:19,510 --> 00:11:29,260
I will check the height value, which will be a float, so we get the value from the user and that will

174
00:11:29,260 --> 00:11:30,130
be of type.

175
00:11:31,180 --> 00:11:31,620
Float.

176
00:11:32,380 --> 00:11:40,660
And then I'm going to get that from, well, you guessed it, hopefully a metric unit height.

177
00:11:40,810 --> 00:11:43,000
Okay, so I'm you getting the height value first here.

178
00:11:43,960 --> 00:11:47,830
So let's get the text to a string to a float.

179
00:11:50,080 --> 00:11:52,360
And divide that by 100.

180
00:11:53,580 --> 00:12:00,990
OK, because we are entering the value in kilograms and then we are going to divide it by 100.

181
00:12:03,150 --> 00:12:12,150
Then let's do the same thing with our height, so we can just copy this and or actually wait, sorry.

182
00:12:12,180 --> 00:12:13,410
We're going to do that with the weight.

183
00:12:13,410 --> 00:12:15,330
No weight value et.

184
00:12:16,140 --> 00:12:17,520
Matrix unit weight.

185
00:12:19,190 --> 00:12:24,860
And we're going to divide the weight, not by 100, so.

186
00:12:26,380 --> 00:12:33,040
Why do we divide by 100 with our height, because we are entering in centimeters?

187
00:12:33,670 --> 00:12:39,220
And we want to get it in meters, so dividing centimeters by 100 is going to give you the meters.

188
00:12:39,850 --> 00:12:40,960
All right, that's what we do here.

189
00:12:41,530 --> 00:12:46,660
And then we can calculate the BMI because the BMI is actually a super simple calculation.

190
00:12:48,570 --> 00:12:59,190
Though, if you search for the formula, you will find that it is weight divided by height in meters

191
00:12:59,400 --> 00:12:59,940
squared.

192
00:13:00,600 --> 00:13:06,510
OK, so weight divided by height, divided by height times 10000.

193
00:13:07,170 --> 00:13:08,850
That's the alternative way.

194
00:13:09,300 --> 00:13:11,310
And when you're working with centimeters, right?

195
00:13:11,700 --> 00:13:18,030
But we're just going to use the meters version, which is why we are dividing by 100 here.

196
00:13:18,900 --> 00:13:20,310
So let's implement that.

197
00:13:20,670 --> 00:13:24,450
Get the weights value and divide it by the Heidfeld value times.

198
00:13:24,450 --> 00:13:26,640
The height volume, which will be height value.

199
00:13:27,560 --> 00:13:36,860
And quite I think I've written it incorrectly, I'm missing the age here, like so OK, so high value

200
00:13:36,860 --> 00:13:39,590
times, high value will give us the BMI.

201
00:13:39,650 --> 00:13:41,240
So this is the calculation for it.

202
00:13:41,780 --> 00:13:44,930
And then what I want to do is I want to display those results.

203
00:13:45,540 --> 00:13:48,500
And this is if the metrics were valid, if they were not valid.

204
00:13:48,950 --> 00:13:54,230
So if we didn't enter anything, then I want to display a toast message.

205
00:13:54,620 --> 00:14:01,010
OK, so I'm just going to use this toast match message, which will say, please enter a valid values.

206
00:14:01,430 --> 00:14:04,760
OK, just toast will be displayed for a short period of time.

207
00:14:05,390 --> 00:14:06,740
And that's pretty much it.

208
00:14:07,370 --> 00:14:12,650
So now here, that's where we want to display the BMI results.

209
00:14:14,110 --> 00:14:18,670
OK, now let's create the function, which will prepare everything for that.

210
00:14:19,150 --> 00:14:19,540
OK.

211
00:14:19,990 --> 00:14:21,880
So I'm going to call this one.

212
00:14:22,990 --> 00:14:25,410
Private fun.

213
00:14:25,630 --> 00:14:29,730
Display BMI results with BMI.

214
00:14:30,770 --> 00:14:38,420
Being a float value that has to be passed as a parameter because, well, I need to use this BMI, which

215
00:14:38,420 --> 00:14:45,740
I just calculate it to then display something onto the screen and I'm going to do it this way.

216
00:14:45,890 --> 00:14:49,730
So of course, you can go ahead and already prepare everything that you want to display.

217
00:14:50,030 --> 00:14:53,570
And we can use binding here to.

218
00:14:54,950 --> 00:15:01,460
Displayed the El Al display BMI result, because currently it's invisible, so we're going to set that

219
00:15:01,460 --> 00:15:04,160
to visible, so you're not visible.

220
00:15:05,540 --> 00:15:06,540
And why is it invisible?

221
00:15:06,570 --> 00:15:10,340
Well, if you look at it, we said it's here to invisible.

222
00:15:11,770 --> 00:15:13,030
And now we're making it visible.

223
00:15:13,780 --> 00:15:17,530
And then we need to set the values accordingly.

224
00:15:18,600 --> 00:15:25,140
We get the BMI value and so forth here, and we then do the calculation and based on the value that

225
00:15:25,140 --> 00:15:26,970
we get there, we are going to write the text.

226
00:15:27,510 --> 00:15:29,690
So let's prepare all of this.

227
00:15:29,850 --> 00:15:35,640
What I'm going to do it like is I'm going to create this BMI label variable, which will be of type

228
00:15:35,640 --> 00:15:36,060
string.

229
00:15:36,600 --> 00:15:41,340
And then I'm going to have a BMI description also of type string.

230
00:15:41,790 --> 00:15:45,120
And I'm going to assign a value to it based on the BMI value.

231
00:15:45,330 --> 00:15:50,010
So the cool thing is I can just use the compare to method.

232
00:15:50,100 --> 00:15:53,070
So there's this compared to method, which allows me to.

233
00:15:54,810 --> 00:16:08,700
Get a value compared to and here I'm going to compare my BMI to 15, so if my BMI is less or equal 15,

234
00:16:09,090 --> 00:16:11,850
then I'm going to say, all right.

235
00:16:13,510 --> 00:16:15,670
Very severely underweight.

236
00:16:16,180 --> 00:16:20,800
And the description will be, oops, you really need to take better care of yourself, eat more.

237
00:16:21,400 --> 00:16:25,780
OK, so that's the case if the BMI is going to be under 15.

238
00:16:26,710 --> 00:16:34,150
So BMI compare if you look at it, so compares this well, you with the specified value for order return

239
00:16:34,150 --> 00:16:34,600
zero.

240
00:16:34,600 --> 00:16:41,080
If this value is equal to the specified other value, a negative number if it's less and the positive

241
00:16:41,350 --> 00:16:43,030
number if it's greater, then.

242
00:16:43,510 --> 00:16:51,310
So if it's zero or less than we know, the BMI is actually going to be less than 15.

243
00:16:51,760 --> 00:16:56,740
OK, and if it's going to be a higher number, then it's going to be bigger.

244
00:16:57,310 --> 00:17:02,080
OK, now of course, you could have just used direct comparison not using this compared to method,

245
00:17:02,080 --> 00:17:04,400
but this is just one way of doing it, OK?

246
00:17:05,800 --> 00:17:12,250
And now we need to do the same thing where we compare it with all the different types of values.

247
00:17:12,579 --> 00:17:17,170
So I'm going to compare it with between is it between 15 and 16?

248
00:17:17,380 --> 00:17:21,970
If that's the case, then we're severely underweight, not very severely on the weight, but severely

249
00:17:21,970 --> 00:17:22,420
underweight.

250
00:17:23,440 --> 00:17:29,410
And then if it's between 16 and eighteen point five, then it's just underweight.

251
00:17:30,660 --> 00:17:38,250
If it's between eighteen point five and twenty five, that's what they call the normal state.

252
00:17:38,530 --> 00:17:44,490
OK, so this is the normal BMI, so it's over eighteen point five, but it's less than 25.

253
00:17:44,850 --> 00:17:51,600
So we have this double and comparison here, and that is going to be what we are checking.

254
00:17:52,050 --> 00:17:52,500
OK.

255
00:17:52,920 --> 00:17:54,290
So this is our next else.

256
00:17:54,330 --> 00:17:56,940
If normal, congratulations, you're in good shape.

257
00:17:57,240 --> 00:18:01,410
Even though that's not necessarily the case, the BMI is not really a good indicator of whether you

258
00:18:01,410 --> 00:18:02,400
are in good shape or not.

259
00:18:02,910 --> 00:18:06,360
OK, and then I'm just going to add the other options in here, OK?

260
00:18:06,960 --> 00:18:08,600
So let's look over them.

261
00:18:09,120 --> 00:18:12,360
If you're between 25 and 30, then you're overweight.

262
00:18:12,360 --> 00:18:17,250
If you're between 30 and 35, then you're obese, class one, moderately obese.

263
00:18:17,850 --> 00:18:24,150
And then if you're between 35 and 40, you're obese class to severely obese and anything higher than

264
00:18:24,150 --> 00:18:24,570
that.

265
00:18:24,600 --> 00:18:27,680
So over 40 is going to be very severely obese.

266
00:18:27,690 --> 00:18:34,050
So there's something wrong with your psyche, probably, and you're eating too much, if that's the

267
00:18:34,050 --> 00:18:34,380
case.

268
00:18:34,950 --> 00:18:41,700
So now what we're doing is we are making our linear layout that we should display this information visible.

269
00:18:41,880 --> 00:18:47,210
But then we also need to make sure that we assign the values to the right properties.

270
00:18:47,220 --> 00:18:50,100
So here or to our right elements that we have.

271
00:18:50,100 --> 00:18:53,820
So we have the BMI description, type and value.

272
00:18:54,180 --> 00:19:00,180
OK, so let's use the value first, which will be just a text that we get from our BMI value and let

273
00:19:00,180 --> 00:19:01,980
me actually calculate this BMI value.

274
00:19:02,400 --> 00:19:05,190
So how do we calculate it as a string?

275
00:19:05,190 --> 00:19:09,240
Because we need to get the BMI value, which is a float that we pass here?

276
00:19:09,360 --> 00:19:16,890
This one, we need to get it into the right format, and in order to do that, we create a new calculation.

277
00:19:16,890 --> 00:19:24,360
Here we can use this big decimal calculation, this method where we get the BMI, we convert it into

278
00:19:24,360 --> 00:19:32,670
a double and then we set the scale to have two values.

279
00:19:33,090 --> 00:19:38,550
So as separator, we look at it and two values pass the comma.

280
00:19:38,880 --> 00:19:42,540
So we're basically cutting anything off past decimal point.

281
00:19:42,540 --> 00:19:46,080
And it's not a comma, it's the dot in English, but in Germany, it's a comma.

282
00:19:46,590 --> 00:19:52,050
And then we can say what kind of rounding mode we want to do, and I'm going to use half even.

283
00:19:52,770 --> 00:19:57,150
OK, and then we convert that into a string.

284
00:19:58,870 --> 00:20:03,670
OK, so quite long calculation, but basically what we're doing is we're taking this float and then

285
00:20:03,670 --> 00:20:09,790
we're breaking it down into a value that will not display anything like twenty five point to one one

286
00:20:09,790 --> 00:20:13,420
one one one three three or whatever, but it will be just cutting it off.

287
00:20:14,170 --> 00:20:14,710
All right.

288
00:20:14,860 --> 00:20:20,110
And now we can use this BMI value to assign it as the BMI value text view.

289
00:20:20,200 --> 00:20:21,490
So this one here?

290
00:20:22,420 --> 00:20:22,860
OK.

291
00:20:23,170 --> 00:20:25,570
And now we just need to set this one and that one.

292
00:20:26,870 --> 00:20:28,880
So let's do that binding.

293
00:20:30,110 --> 00:20:30,860
TV.

294
00:20:31,190 --> 00:20:33,740
And we had the.

295
00:20:35,490 --> 00:20:37,020
Type here.

296
00:20:38,150 --> 00:20:41,540
So let's set the text for the type to be the BMI label.

297
00:20:42,440 --> 00:20:44,930
So this one here, obese class and so forth.

298
00:20:45,740 --> 00:20:46,700
And then finally.

299
00:20:48,250 --> 00:20:54,220
Just need to set the description as well, which is a Nullarbor, so we at the question mark and this

300
00:20:54,220 --> 00:20:56,170
will be the EMI description.

301
00:20:56,860 --> 00:21:02,040
OK, so that's pretty much what our display BMI value method should do.

302
00:21:02,050 --> 00:21:05,770
And here we just need to call this method once we click on the button.

303
00:21:06,070 --> 00:21:11,260
OK, and here we need to pass the BMI, and that should pretty much do the trick.

304
00:21:11,260 --> 00:21:12,790
So let's see.

305
00:21:13,880 --> 00:21:16,400
If this is going to work for our application as well.

306
00:21:23,540 --> 00:21:28,790
So that we are let's click on BMI and there's still something wrong with my positioning there.

307
00:21:28,880 --> 00:21:31,010
But let's just test if it works technically.

308
00:21:31,460 --> 00:21:38,600
So here's 70 to hide, 169 again, calculate and we see it all seems to be fine.

309
00:21:38,930 --> 00:21:41,600
OK, so now it just seems to my.

310
00:21:44,180 --> 00:21:46,530
Texts should be underneath the activity.

311
00:21:46,880 --> 00:21:52,190
I my toolbar should be on top of the other item here, so.

312
00:21:55,530 --> 00:21:59,220
So actually, I want my toolbar to be on top off.

313
00:21:59,640 --> 00:22:01,830
So this means that this one should be below.

314
00:22:02,010 --> 00:22:02,910
So below.

315
00:22:03,390 --> 00:22:06,210
Lay out below and it should be the toolbar.

316
00:22:07,390 --> 00:22:12,940
BMI calculation, so let me see if that fixes the problem and if that's the case, then we're done for

317
00:22:12,940 --> 00:22:16,780
this video and not the exercise, but the BMI calculator.

318
00:22:16,810 --> 00:22:18,250
Yeah, we're good to go.

319
00:22:18,640 --> 00:22:19,600
So that's pretty much it.

320
00:22:19,640 --> 00:22:25,900
Now you could, of course, also use the button and put it just here, somewhere directly underneath

321
00:22:25,900 --> 00:22:28,330
the edit text or even at the bottom of the screen.

322
00:22:28,600 --> 00:22:33,010
So it's really up to you how you want to position all of your user interface items.

323
00:22:33,340 --> 00:22:34,540
So that's it for this video.

324
00:22:34,990 --> 00:22:35,830
See you in the next one.

