1
00:00:00,630 --> 00:00:01,330
Welcome back.

2
00:00:01,350 --> 00:00:05,760
And this video, we are going to add the history button, so once you click on it, you can see we go

3
00:00:05,760 --> 00:00:07,110
to the history activity.

4
00:00:07,120 --> 00:00:08,000
For now, it's empty.

5
00:00:08,010 --> 00:00:14,190
But later on, it will be a recycled view, which contains all of the finished exercises that we had.

6
00:00:14,190 --> 00:00:18,450
So we also need to store those finished exercises at one point.

7
00:00:18,690 --> 00:00:19,760
But that's what we're going to do later.

8
00:00:19,770 --> 00:00:22,530
For now, we just need to get to the point where we have this.

9
00:00:22,530 --> 00:00:22,860
You are.

10
00:00:22,890 --> 00:00:25,990
So that's the challenge for this video.

11
00:00:26,010 --> 00:00:27,540
You can try to build that yourself.

12
00:00:27,780 --> 00:00:28,980
You will need to have this image.

13
00:00:28,980 --> 00:00:34,410
You can find it inside of the project that you can download and then you just go ahead.

14
00:00:34,440 --> 00:00:39,810
Of course, this year is a linear layout where things are next to each other, so where the UI elements

15
00:00:39,810 --> 00:00:41,470
here are next to each other.

16
00:00:41,490 --> 00:00:45,930
So it has to be in a horizontal perspective or orientation.

17
00:00:46,380 --> 00:00:49,910
And then, of course, this year should always be important.

18
00:00:50,100 --> 00:00:52,350
So this activity should always be portrait mode.

19
00:00:52,770 --> 00:00:56,170
And yeah, that's pretty much going to be it for now.

20
00:00:57,090 --> 00:00:59,820
So you just need to create the intent.

21
00:00:59,820 --> 00:01:04,900
You need to set the title here to history and basically that's it.

22
00:01:04,920 --> 00:01:06,360
So you can try to build that yourself.

23
00:01:06,360 --> 00:01:08,820
Otherwise, of course, just follow along with the video.

24
00:01:09,570 --> 00:01:10,020
All right.

25
00:01:10,020 --> 00:01:10,920
So let's get started.

26
00:01:10,950 --> 00:01:19,030
The first thing we need to do is to add a little icon on our page, which is our main activities.

27
00:01:19,050 --> 00:01:21,480
So let's go to the activity main XML.

28
00:01:22,570 --> 00:01:28,240
Here and there, we need to add a button here at the bottom.

29
00:01:28,840 --> 00:01:33,580
Well, the thing is currently we just have this linear layout, which.

30
00:01:34,600 --> 00:01:36,190
Contains our.

31
00:01:37,440 --> 00:01:43,350
Button here, which just this BMI button, right, but we need the same structure once again, and that

32
00:01:43,350 --> 00:01:45,330
should be inside another linear layout.

33
00:01:46,500 --> 00:01:50,310
Because you know how to build linear layouts, I'm just going to pace the code in here.

34
00:01:52,100 --> 00:01:58,700
And then we will look at everything, OK, so I pasted the code and here it starts here where we finished

35
00:01:58,700 --> 00:02:00,630
off with our start.

36
00:02:00,950 --> 00:02:05,000
So, yeah, this is the text you start, which is this icon that we had there.

37
00:02:05,000 --> 00:02:05,270
Right.

38
00:02:05,300 --> 00:02:11,090
So this linear layout which contains our start again can so is this one here.

39
00:02:11,270 --> 00:02:14,660
So underneath that's where this linear layout starts.

40
00:02:15,080 --> 00:02:21,980
We can see that I said the orientation to horizontal gravity centered margin top 30 and I'm using base

41
00:02:21,980 --> 00:02:23,000
line aligned.

42
00:02:24,230 --> 00:02:27,360
And what base line A thus is what you can find here.

43
00:02:27,710 --> 00:02:29,420
So we have an example.

44
00:02:29,420 --> 00:02:32,920
If base line a line is set to force, that's the result.

45
00:02:32,930 --> 00:02:37,700
We get a baseline, a line is set to true, then that's the result that we get.

46
00:02:39,270 --> 00:02:45,600
Because as you can see now, the text has two lines, so to speak, and now the baseline is aligned

47
00:02:45,600 --> 00:02:48,720
accordingly, but that's not necessarily what you want.

48
00:02:48,780 --> 00:02:51,420
So sometimes you just don't want to set this to true.

49
00:02:52,110 --> 00:02:54,120
That's why we said it directed to false.

50
00:02:54,920 --> 00:02:55,130
Right.

51
00:02:55,150 --> 00:02:57,080
We've used it before, but I didn't explain it there.

52
00:02:57,090 --> 00:02:59,820
But now you can see what it's used for.

53
00:03:00,210 --> 00:03:00,630
All right.

54
00:03:00,630 --> 00:03:04,490
Then we have this other linear layout and another linear layout.

55
00:03:04,620 --> 00:03:11,190
So this very Ortolani allowed is the overall linear layout where the two buttons should be next to each

56
00:03:11,190 --> 00:03:11,450
other.

57
00:03:11,820 --> 00:03:18,270
But then we have another linear layout, which is this BMI button and then the linear layout, which

58
00:03:18,270 --> 00:03:21,670
contains the BMI button and also the calculator text view.

59
00:03:22,260 --> 00:03:24,950
So this is just a text for BMI.

60
00:03:25,110 --> 00:03:28,500
And then we have another text you, which is this calculator, so.

61
00:03:29,370 --> 00:03:35,310
This button itself is a linear layout, and then this calculated text is in another linear level which

62
00:03:35,310 --> 00:03:39,730
surrounds it, and then there's another linear layout which puts those two buttons next to each other.

63
00:03:39,750 --> 00:03:43,230
So that's why we need so many different linear layouts.

64
00:03:43,620 --> 00:03:50,430
So basically, I just pasted the old linear layout we had before inside of it because that's what we

65
00:03:50,430 --> 00:03:51,650
already had built before.

66
00:03:51,660 --> 00:03:51,970
Right.

67
00:03:52,290 --> 00:03:58,800
And now I have another linear layout surrounding it in which I'm just saying, OK, I want to put stuff

68
00:03:58,800 --> 00:03:59,600
next to each other.

69
00:03:59,730 --> 00:04:03,150
So that's why I'm using this horizontal orientation.

70
00:04:04,460 --> 00:04:10,520
And then, of course, inside this ultra linear lab, we have another one, which is going to be our

71
00:04:10,520 --> 00:04:13,690
calendar button and it has the same structure.

72
00:04:13,700 --> 00:04:17,510
So we have a linear layout where things are vertically oriented.

73
00:04:17,899 --> 00:04:20,570
So our UI elements are vertically oriented.

74
00:04:20,959 --> 00:04:25,490
And then we have this linear layout, which is, first of all, the icon itself.

75
00:04:26,030 --> 00:04:31,640
So this little icon button and then the TextView, which is underneath it, which is.

76
00:04:32,700 --> 00:04:35,320
This history, TextView, all right.

77
00:04:35,460 --> 00:04:40,650
And that's pretty much it, so, of course, we need to have this icy calendar image and of course,

78
00:04:40,650 --> 00:04:44,700
you can download it from the project, as we've done before.

79
00:04:46,550 --> 00:04:54,110
So just download the image and then drag it or paste it into your resources folder and to this drawable

80
00:04:54,110 --> 00:04:54,560
folder.

81
00:04:58,350 --> 00:05:00,720
Now, let's see if this guy already works.

82
00:05:02,740 --> 00:05:09,070
And we are so of course, it doesn't do anything yet because we can't click on it, we haven't implemented

83
00:05:09,070 --> 00:05:09,990
any functionality.

84
00:05:10,000 --> 00:05:12,930
But overall, you can see that this is our history.

85
00:05:12,940 --> 00:05:13,690
I can hear.

86
00:05:15,950 --> 00:05:19,790
All right, now let's create the activity so the history activity.

87
00:05:21,030 --> 00:05:26,730
And I'm going to create a new activity, which is going to be an empty activity, and I'm going to call

88
00:05:26,730 --> 00:05:27,000
it.

89
00:05:28,340 --> 00:05:31,010
History activity.

90
00:05:37,160 --> 00:05:43,560
Once it's done, I go to the manifest because I also want to have the same rules apply.

91
00:05:43,580 --> 00:05:49,160
So the screen orientation and the theme should be the same as with all of the other activities.

92
00:05:49,160 --> 00:05:54,560
So I'm just going to add that in here across the screen, orientation is going to complain, but I'm

93
00:05:54,560 --> 00:05:55,970
just going to leave it as is.

94
00:05:57,070 --> 00:06:03,580
And this additional hero is not necessary, as well as the keyword here, so what's important is that

95
00:06:03,790 --> 00:06:05,620
the activity is closing correctly.

96
00:06:06,190 --> 00:06:08,640
All right, so that's our manifest.

97
00:06:08,860 --> 00:06:12,970
The next thing we need to set up is the history.

98
00:06:14,060 --> 00:06:19,490
XML file, because in here we don't have anything right, but I'm just going to use a linear layout

99
00:06:19,490 --> 00:06:27,470
here instead of this constraint layout, so linear layout and inside of this linear layout, I want

100
00:06:27,470 --> 00:06:34,250
to have a toolbar and I want to use the same kind of toolbar that I've used in other XML files before.

101
00:06:35,180 --> 00:06:41,690
So I'm just going to open up the activity, BMI, XML file, and I'm going to copy the toolbar from

102
00:06:41,690 --> 00:06:45,020
there, so let's add that in here as well.

103
00:06:45,770 --> 00:06:51,850
Of course, I'm going to give it a different name, so I'm going to call this one toolbar history activity.

104
00:06:53,400 --> 00:07:00,090
And then inside of the history activity, I'm going to add the same code that we had here where we set

105
00:07:00,900 --> 00:07:07,650
the bar, so set Support Action Bar, as well as adding the toolbar functionality.

106
00:07:07,650 --> 00:07:10,020
So I'm just going to copy this code here as well.

107
00:07:10,290 --> 00:07:12,990
So I'm going to paste it inside of my uncreate.

108
00:07:12,990 --> 00:07:19,860
And I don't need to import this element because I'm not going to use that one, because I'm just going

109
00:07:19,860 --> 00:07:22,790
to use toolbar history activity.

110
00:07:23,760 --> 00:07:30,090
And here, of course, it's also the toolbar history activity that we need to set for the navigation

111
00:07:30,090 --> 00:07:30,920
and click listener.

112
00:07:31,200 --> 00:07:35,340
And the action bar title should not be calculate PMI, but it should be history.

113
00:07:36,960 --> 00:07:43,500
All right, now we only need to intent, which leads us to get here, so let's go to our main activity.

114
00:07:44,530 --> 00:07:50,550
And there we had this intent, which led us to the exercise activity to be my activity and so forth,

115
00:07:50,770 --> 00:07:52,660
so we're going to do the same thing here as well.

116
00:07:53,050 --> 00:07:56,200
And it's going to be El Al history.

117
00:07:57,180 --> 00:08:04,350
And I'm going to use pretty much the same code that we did here as well, so set on Click Listener,

118
00:08:04,350 --> 00:08:09,880
but of course it's the history activity that we want to move over to.

119
00:08:10,560 --> 00:08:11,060
OK.

120
00:08:11,100 --> 00:08:11,880
And that's pretty much it.

121
00:08:11,910 --> 00:08:14,630
So there was nothing new here, nothing too fancy.

122
00:08:15,030 --> 00:08:17,950
We really use the same structures that we have used before.

123
00:08:17,970 --> 00:08:20,820
That's why I really went over this very quickly.

124
00:08:21,150 --> 00:08:26,640
If anything of that didn't make sense to you, then check out all the videos on the topic that didn't

125
00:08:26,640 --> 00:08:31,410
make sense to you, OK, because basically it's really the same thing that we've done before multiple

126
00:08:31,410 --> 00:08:32,010
times already.

127
00:08:32,370 --> 00:08:37,890
So pressing on this report and you can see I get to this new activity which says history.

128
00:08:38,010 --> 00:08:40,960
When I press on the button, I get back to my start activity.

129
00:08:41,340 --> 00:08:41,700
All right.

130
00:08:41,700 --> 00:08:46,460
So now we have prepared everything for our history site.

131
00:08:46,560 --> 00:08:52,170
So for our history activity, of course, we now need to create a recycler view, but we also need to

132
00:08:52,320 --> 00:08:55,470
look into storing data with SQLite.

133
00:08:56,670 --> 00:08:59,490
So let's do that and see you in the next video.

