1
00:00:00,390 --> 00:00:01,180
Hi everyone.

2
00:00:01,260 --> 00:00:04,980
So now it's time to implement the main activity class.

3
00:00:04,980 --> 00:00:10,930
So first of all just open the app folder and then open the rest folder here inside these terrorist folder

4
00:00:10,950 --> 00:00:16,700
we have this layer folder open it and here you can see the content underlined when that example just

5
00:00:16,700 --> 00:00:19,580
publicly on the spot in order to open this file here.

6
00:00:19,890 --> 00:00:21,940
So this is our content underline minute examen.

7
00:00:21,950 --> 00:00:27,310
And you can see that inside this componentry the constraint lay out a layout is actually the main way

8
00:00:27,310 --> 00:00:28,160
out here.

9
00:00:28,440 --> 00:00:31,440
So at the bottom here you can see this text tap.

10
00:00:31,470 --> 00:00:35,970
Just click on it so you can see that we have actually our concerns they are.

11
00:00:36,090 --> 00:00:38,130
So I don't want a constraint there.

12
00:00:38,180 --> 00:00:39,700
You want a scroll view.

13
00:00:39,750 --> 00:00:40,280
OK.

14
00:00:40,440 --> 00:00:46,440
So let's actually change at this opening tag here you can see the name is Android that supports that

15
00:00:46,440 --> 00:00:48,350
constraint that constraints play out.

16
00:00:48,360 --> 00:00:50,210
So just delete this name here.

17
00:00:50,230 --> 00:00:52,770
I just step in here scroll view.

18
00:00:52,940 --> 00:00:56,030
OK so this is going to be the pattern to play out.

19
00:00:56,110 --> 00:01:00,140
And now let's actually give an ID to this scroll view.

20
00:01:00,140 --> 00:01:04,800
So before the alien tag here of this scroll view let's create a new line.

21
00:01:04,820 --> 00:01:10,260
Just type in here ID and choose and sign Plus Id slash.

22
00:01:10,540 --> 00:01:12,630
And he had to step in here.

23
00:01:12,660 --> 00:01:18,420
The idea is going to be scroll view actually scroll view right.

24
00:01:18,430 --> 00:01:20,270
So this is going to be the ID.

25
00:01:20,440 --> 00:01:22,860
Now let's go to the main activity class here.

26
00:01:22,960 --> 00:01:27,250
So inside these Apfel that open the stub a folder and then open this package.

27
00:01:27,340 --> 00:01:31,630
And here you can see the main activity class doubleclick on this file here in order to make you know

28
00:01:31,700 --> 00:01:32,730
that all of these files.

29
00:01:32,920 --> 00:01:37,820
Now let's double click on this tab here an activity that job in order to make this area right there.

30
00:01:38,080 --> 00:01:39,880
So this is our main activity class.

31
00:01:39,970 --> 00:01:47,290
Let's go to this class let's actually here create some valuables inside this main activity class.

32
00:01:47,320 --> 00:01:51,420
So the first variable is going to be a type database handler right.

33
00:01:51,430 --> 00:01:58,660
So just step here private database handler database handler semicolon create another variable of type

34
00:01:58,660 --> 00:02:07,930
double so private double and the name of this value is going to be total total price total martial arts

35
00:02:07,930 --> 00:02:13,950
price total martial arts price semicolon.

36
00:02:14,050 --> 00:02:21,600
Now let's create actually a valuable or five scroll view so private scroll view scroll view semicolon

37
00:02:22,510 --> 00:02:29,520
and here because I want to actually put the martial art objects as buttons inside our scroll view in

38
00:02:29,520 --> 00:02:30,630
the main activity.

39
00:02:30,970 --> 00:02:38,180
I want to specify that each martial arts button is going to take only a half of the view of the screen.

40
00:02:38,500 --> 00:02:40,880
So just typing here private's it.

41
00:02:41,200 --> 00:02:44,950
Martial art martial art button

42
00:02:48,250 --> 00:02:49,230
semi-hollow.

43
00:02:49,510 --> 00:02:55,690
So here let's go to this uncreate method and let's initialize our valuables that we declared inside

44
00:02:55,690 --> 00:02:56,520
the class.

45
00:02:56,530 --> 00:03:02,400
I mean I think the first value is going to be database handler assignment operator new database handler.

46
00:03:02,440 --> 00:03:03,050
That's it.

47
00:03:03,220 --> 00:03:06,850
And here in say the prentices we just have to pass the context.

48
00:03:06,850 --> 00:03:11,190
The context is main activity that this semicolon.

49
00:03:11,530 --> 00:03:14,440
So now let's initialize this total martial arts prize.

50
00:03:14,470 --> 00:03:20,260
So notice that these variables that we created inside this class are actually instance variables and

51
00:03:20,260 --> 00:03:23,090
instance variables have default values.

52
00:03:23,110 --> 00:03:23,580
OK.

53
00:03:23,830 --> 00:03:28,870
So when I say initialize this means that you want to assign my own value to these variables.

54
00:03:29,080 --> 00:03:35,050
So let's pass the value zero point zero here let's assign this value to these rowdier but total total

55
00:03:35,050 --> 00:03:38,940
Musharraf's price and let's initialises this scroll view.

56
00:03:38,980 --> 00:03:45,830
Assignment operator let's cast this object through to a scroll you object find view by Id find viewpoint

57
00:03:45,910 --> 00:03:49,230
ID or that ID that scurvy.

58
00:03:49,660 --> 00:03:56,260
So notice that we actually created this idea here inside that content and then I mean it is I and if

59
00:03:56,260 --> 00:04:02,750
I go to this fight here you can see that you specified an ID for the scroll view here.

60
00:04:02,800 --> 00:04:04,760
So let's go back to the main activity class.

61
00:04:04,780 --> 00:04:11,840
So here I can say scroll view scroll view sometimes the autocomplete feature of Android studio is nothing

62
00:04:11,890 --> 00:04:16,400
to help you to for example refer to an SMS to a specific ID.

63
00:04:16,470 --> 00:04:20,590
So in that case you just need to manually write that idea here.

64
00:04:20,800 --> 00:04:27,610
Like the style scroll you and then here I need to initialize the mouse in order to actually calculate

65
00:04:27,640 --> 00:04:29,500
the width of the screen.

66
00:04:29,650 --> 00:04:35,140
We need to create a variable of type point so to step in here point and the name of this variable is

67
00:04:35,140 --> 00:04:43,070
going to be screen with screen which is I mean operator new point so at the end of her statement let's

68
00:04:43,070 --> 00:04:51,800
put a semicolon here and let's just type it here get window manager get default display that good size

69
00:04:52,250 --> 00:04:56,690
and let's pass this screen to this valuable here.

70
00:04:56,690 --> 00:04:59,110
So let's change the screen to screen size.

71
00:04:59,120 --> 00:05:01,410
Actually it's more meaningful here.

72
00:05:01,640 --> 00:05:02,660
So the screen size.

73
00:05:02,780 --> 00:05:05,550
Let's change this one to also screen size.

74
00:05:05,630 --> 00:05:10,810
Because here we want to first get the screen size and then we can get the width of the screen.

75
00:05:10,910 --> 00:05:11,400
OK.

76
00:05:11,630 --> 00:05:17,140
So first we have a variable of a point and then we want to get the screen size by just calling to get

77
00:05:17,150 --> 00:05:22,610
window manager to get the part display that gets size so the size is going to be assigned to this screen

78
00:05:22,610 --> 00:05:24,410
size variable here.

79
00:05:24,440 --> 00:05:26,040
Now I can get that screen with.

80
00:05:26,050 --> 00:05:31,090
So now let's refer to our martial art Potten with assignment operator.

81
00:05:31,190 --> 00:05:38,820
So now we have the screen size so the screen size that X semicolon that that's now the width of the

82
00:05:38,820 --> 00:05:43,100
screen is actually assigned to this monitor that button.

83
00:05:43,250 --> 00:05:47,830
But now we want to divide the width of the screen by two.

84
00:05:47,870 --> 00:05:52,780
So this means that the value that is going to be assigned to this variable marshal that button which

85
00:05:53,120 --> 00:05:58,340
is actually half the value of the half of the screen OK half of that half of the width of the screen

86
00:05:58,340 --> 00:05:58,980
actually.

87
00:05:59,180 --> 00:05:59,970
Right.

88
00:06:00,080 --> 00:06:05,240
So this means that I want my button to take half of the width of this screen.

89
00:06:05,600 --> 00:06:14,360
And finally we need to actually call the modify user interface modify user interface and then put a

90
00:06:14,360 --> 00:06:16,270
pair of Prentice's here semi-colon.

91
00:06:16,700 --> 00:06:25,820
So now I told you that root objects are going to be represented as buttons to the user inside the content

92
00:06:25,850 --> 00:06:32,030
and they let me index them and so this means that we need to create a subclass of button called martial

93
00:06:32,090 --> 00:06:38,930
art Potin so that we can actually provide some specific features for that button.

94
00:06:39,050 --> 00:06:40,910
So let's create a new class for that.

95
00:06:40,910 --> 00:06:43,400
Let's open the Android view here.

96
00:06:43,790 --> 00:06:48,350
So you know how to do that you just click on a view at the top to the windows and then project.

97
00:06:48,590 --> 00:06:55,910
And here just open this Joe a folder and then you just select this package directly cut it new and then

98
00:06:56,480 --> 00:06:58,370
just click on jobs class.

99
00:06:58,490 --> 00:06:58,970
OK.

100
00:06:59,150 --> 00:07:01,160
So for the name of the class here.

101
00:07:01,280 --> 00:07:02,250
Just step in here.

102
00:07:02,270 --> 00:07:10,270
Martial arts martial art but in martial arts and so this is the class here don't change anything just

103
00:07:10,310 --> 00:07:10,610
the kind.

104
00:07:10,650 --> 00:07:11,750
OK.

105
00:07:12,090 --> 00:07:15,940
So this is our martial art bottom class right.

106
00:07:15,960 --> 00:07:19,370
Let me just double click on the top here in order to make this area wider.

107
00:07:19,440 --> 00:07:24,610
So here because we want to create a subclass of Potten So we want the same button.

108
00:07:24,670 --> 00:07:28,980
Ok but I want to add some extra features to that button.

109
00:07:29,040 --> 00:07:36,390
So this means that our class marshal of the button must inherit from the app compact button class so

110
00:07:36,390 --> 00:07:42,090
I can say here extends app compact button.

111
00:07:42,390 --> 00:07:48,370
So this means that now our class marshal button is actually a subclass of the bottom class in Android.

112
00:07:48,660 --> 00:07:52,250
So let's go into the curly braces of this class first.

113
00:07:52,290 --> 00:07:59,350
Let's create a variable of type martial arts suggests they can hear Private martial art and the name

114
00:07:59,350 --> 00:08:05,030
of this valuable is martial art object martial art object semi-colon.

115
00:08:05,290 --> 00:08:08,960
Now let's create a constructor for this class.

116
00:08:08,960 --> 00:08:14,650
So just sitting here Puplick martial arts Potten put a pair of Prentice's here.

117
00:08:14,650 --> 00:08:23,800
First we need to specify the context here context comma and then we need to specify actually an argument

118
00:08:23,830 --> 00:08:27,510
or a perimeter in order to initialize or marshal or object body.

119
00:08:27,530 --> 00:08:33,990
But in this value actually so I can't say martial art martial arts.

120
00:08:34,120 --> 00:08:34,700
Right.

121
00:08:35,030 --> 00:08:42,070
So now let's open and close this constructor by using these curly braces inside the constructor.

122
00:08:42,180 --> 00:08:48,830
First need to call the constructor of the superclass which is going to be the app compatibility in class.

123
00:08:48,830 --> 00:08:49,530
Right.

124
00:08:49,580 --> 00:08:54,430
So I can say super And then we need to pass the context.

125
00:08:54,620 --> 00:08:55,740
That's it.

126
00:08:55,760 --> 00:08:57,960
Right now you can see that we have no errors.

127
00:08:58,190 --> 00:09:03,080
And finally we can initialize our instance variables to marshal object.

128
00:09:03,080 --> 00:09:06,080
Assignment operator martial art semi-colons.

129
00:09:06,290 --> 00:09:11,360
I am assigning this argument to this instance variable a martial art object.

130
00:09:11,360 --> 00:09:15,260
Now let's create some Kjetil my fits so I can say public.

131
00:09:15,800 --> 00:09:21,890
And the first method is going to actually turn a string by the way that is going to represent the color

132
00:09:21,920 --> 00:09:23,680
of that martial art.

133
00:09:23,690 --> 00:09:32,980
So I can't say public strange return or get martial art color get that color and then put a pair of

134
00:09:32,980 --> 00:09:36,510
panties here open and close this method by using these curly braces.

135
00:09:36,580 --> 00:09:38,260
And here's just three turn.

136
00:09:38,460 --> 00:09:45,410
Marshall object that color that actually gets rid of color right semi-colon.

137
00:09:45,700 --> 00:09:52,250
Let's create another method so public and here this time I want to return the modular price.

138
00:09:52,320 --> 00:09:58,450
So the return type of this method is going to be double the day of this it is going to be get Marshall

139
00:09:58,590 --> 00:10:04,820
Price get Mosteller price and put a pair of parenthesis here.

140
00:10:05,010 --> 00:10:15,470
Open and close this by using these curly braces return Marshall object that gets Marshall Price semicolon.

141
00:10:15,550 --> 00:10:16,370
So that's it.

142
00:10:16,630 --> 00:10:19,900
Let's go back to our main activity class here.

143
00:10:19,900 --> 00:10:22,280
So this is our master class right.

144
00:10:22,540 --> 00:10:28,150
So let's go back out toward me and I give the class here and let's provide an implementation let's create

145
00:10:28,210 --> 00:10:32,760
a method called modify user interface here inside our class.

146
00:10:32,800 --> 00:10:38,950
So after the in curly brace of these uncreate method I'm going to create that method here so I'm going

147
00:10:38,950 --> 00:10:45,740
to say private's void the name of this if it is modify use interface just with a set of practices you

148
00:10:46,100 --> 00:10:49,360
open and close this method by using these curly braces here.

149
00:10:49,370 --> 00:10:52,030
So now let's pro-white an implementation for this method.

