1
00:00:00,420 --> 00:00:01,970
So now I want to let you know.

2
00:00:01,980 --> 00:00:03,930
Another important point.

3
00:00:03,960 --> 00:00:07,690
So let's actually get me to show you the structure of the project.

4
00:00:07,710 --> 00:00:12,020
So let's actually click on The View tool windows and then project.

5
00:00:12,300 --> 00:00:19,250
And as you can see here inside this it's folder if you have tame animals as you can see here in nature

6
00:00:19,250 --> 00:00:20,200
to open this fall.

7
00:00:20,270 --> 00:00:22,100
And you can see these tame animals.

8
00:00:22,100 --> 00:00:26,240
And as you can see here all these images are dot PND.

9
00:00:26,330 --> 00:00:27,700
Right.

10
00:00:27,770 --> 00:00:32,180
The format of these images are thought PFG and Enceladus avoid animals.

11
00:00:32,210 --> 00:00:37,290
As you can see we have also thought PAGG image is right but we have this image which is actually that

12
00:00:37,290 --> 00:00:38,210
JP.

13
00:00:38,660 --> 00:00:44,660
So because you want to actually interact with the name of these images from our Java code it's better

14
00:00:44,660 --> 00:00:47,950
that all of them be actually of the same format.

15
00:00:47,960 --> 00:00:55,580
So let's actually delete this image while and then underline animals dash ph underline punter that GGP.

16
00:00:55,850 --> 00:01:01,910
OK so if you want to use this image make sure to change the format of this image and then you can actually

17
00:01:01,910 --> 00:01:04,210
use it inside your own application.

18
00:01:04,310 --> 00:01:10,790
But for this application because the format of all these images is actually data P in G.

19
00:01:10,850 --> 00:01:14,960
It's better to all of them be of the same format.

20
00:01:15,110 --> 00:01:21,790
So let's just select this image and then presently key on your keyboard and then click on OK.

21
00:01:21,980 --> 00:01:24,100
So now that image is actually deleted.

22
00:01:24,560 --> 00:01:29,230
And now that's actually the go inside our main activity the job file here.

23
00:01:29,560 --> 00:01:30,890
And as you can see here.

24
00:01:31,190 --> 00:01:34,940
Let's actually go inside these and create options menu.

25
00:01:35,180 --> 00:01:41,350
As you can see here we have these on create options menu and we have this on options items selected.

26
00:01:41,570 --> 00:01:45,680
OK so now let's run our project and see what happens.

27
00:01:45,680 --> 00:01:51,140
So as you can see here our application is actually running on this emulator.

28
00:01:51,620 --> 00:01:59,090
And now as you can see here at the top we have this action bar and if you want to click on this a certain

29
00:01:59,090 --> 00:02:01,550
spot in here settings image as you can see.

30
00:02:01,550 --> 00:02:05,210
Now we want to transition to their settings activity.

31
00:02:05,210 --> 00:02:06,050
Right.

32
00:02:06,110 --> 00:02:08,330
So as you can see here we have this image here right.

33
00:02:08,340 --> 00:02:15,560
So this method uncreate options menu is going to actually put this item here inside this action bar.

34
00:02:15,560 --> 00:02:18,850
So that's the job of this uncreate options menu.

35
00:02:19,340 --> 00:02:23,150
So we have already dismissed it here with the default implementation.

36
00:02:23,160 --> 00:02:27,950
So if it is OK we don't need to change the implementation of this method.

37
00:02:28,640 --> 00:02:31,720
And now let's actually look at our method here.

38
00:02:31,760 --> 00:02:35,670
On option items selected right on options items selected.

39
00:02:35,840 --> 00:02:38,910
So now we need to actually change the Smurfette here.

40
00:02:39,320 --> 00:02:41,770
We need to change the implementation of this method.

41
00:02:41,840 --> 00:02:48,740
And as you can see here we have some comments here that says handle action but item clique's here the

42
00:02:48,740 --> 00:02:54,820
action bar will automatically handle clicks on the home or part of button.

43
00:02:55,040 --> 00:03:00,310
So long as you specify parent activity in Android manifest that XML.

44
00:03:00,440 --> 00:03:00,910
Right.

45
00:03:01,040 --> 00:03:04,930
So now let's actually delete these lines of code.

46
00:03:04,930 --> 00:03:07,360
Here is implementation.

47
00:03:07,610 --> 00:03:10,640
And now let's actually put our own implementations here.

48
00:03:10,850 --> 00:03:17,090
So I'm going to pasting some lines of code here and then I'm going to explain to you what's going on

49
00:03:17,090 --> 00:03:17,680
here.

50
00:03:17,900 --> 00:03:25,220
So as you can see here these are two lines of code that I pasted here and in length 60 free as you can

51
00:03:25,220 --> 00:03:28,460
see I created an instance of type intent.

52
00:03:28,460 --> 00:03:30,740
I created an intent object here.

53
00:03:30,830 --> 00:03:35,120
And the name of my instance is preference intent.

54
00:03:35,450 --> 00:03:41,050
And then I put an assignment operator here as you can see I am actually creating a new instance of type

55
00:03:41,060 --> 00:03:41,440
into it.

56
00:03:41,450 --> 00:03:42,280
Right.

57
00:03:42,290 --> 00:03:48,570
So new intent and as he has it here this actually accepts two arguments the constructor of this intense

58
00:03:48,590 --> 00:03:55,460
class actually accepts two arguments but the first one is the context main activity that this comma

59
00:03:55,760 --> 00:04:00,150
and the second argument is the activity that we want to transition to.

60
00:04:00,530 --> 00:04:06,650
Which is actually setting's activity that class of we haven't still created this activity yet inside

61
00:04:06,710 --> 00:04:07,330
our project.

62
00:04:07,330 --> 00:04:17,060
So we need to create this activity now and actually look at our code here in our line 64 start activity

63
00:04:17,060 --> 00:04:19,800
Prefect's activity our preference intent right.

64
00:04:19,940 --> 00:04:26,210
So this means that whenever we use that actually clicks on these on the options I'd have selected so

65
00:04:27,250 --> 00:04:27,710
far.

66
00:04:27,860 --> 00:04:30,780
So now let me actually show you the emulator.

67
00:04:30,950 --> 00:04:37,190
Now whenever the user clicks on this image here on this setting's image it's going to actually transition

68
00:04:37,190 --> 00:04:41,960
to the settings activity that class start activity preferences intent.

69
00:04:42,260 --> 00:04:42,770
Right.

70
00:04:42,770 --> 00:04:43,700
So it's going to start.

71
00:04:43,700 --> 00:04:50,330
The preference is going to start the settings activity here whenever the user clicks on these settings

72
00:04:50,410 --> 00:04:51,130
image.

73
00:04:51,500 --> 00:04:58,940
And here finally we are returning this value so returns super that an options item selected item.

74
00:04:59,120 --> 00:05:05,120
OK so because this if it actually meets the return value of that bullion we need to really put this

75
00:05:05,120 --> 00:05:12,050
thing in here return super so superior refers to the superclass right supertax on options items selected

76
00:05:12,350 --> 00:05:16,080
and we passed this item as the argument of this misfit.

77
00:05:16,520 --> 00:05:20,290
So now the create another activity inside our project.

78
00:05:20,300 --> 00:05:30,720
So now let's create a view to Windows and then project beautiful windows project and then just now just

79
00:05:31,040 --> 00:05:36,250
double click this job a folder here and then publicly turn this package here.

80
00:05:37,250 --> 00:05:46,170
So now just click on File New and then click on activity and here choose basic activity right.

81
00:05:46,190 --> 00:05:49,820
And for the name of your activity just type in here citizens

82
00:05:53,620 --> 00:05:54,270
activity

83
00:05:57,530 --> 00:05:58,080
right.

84
00:05:58,110 --> 00:06:04,220
So the name of the activities setting's activity the lay out name is activity underline settings.

85
00:06:04,440 --> 00:06:06,950
The title is setting's activity.

86
00:06:07,050 --> 00:06:10,880
We don't want these settings activity to be the luncher activities.

87
00:06:10,950 --> 00:06:13,120
Do not check to search box here.

88
00:06:13,500 --> 00:06:19,250
And we also need a fragment for this activity so check the search box here use a fragment.

89
00:06:19,380 --> 00:06:24,840
And here at the bottom it says if true the content will be affreightment right.

90
00:06:24,870 --> 00:06:29,960
So when you check the box here it says if true the content to be affreightment.

91
00:06:30,030 --> 00:06:30,890
So OK.

92
00:06:31,890 --> 00:06:39,130
And now we also want to specify a hierarchical parent for these settings activity.

93
00:06:39,300 --> 00:06:40,830
So just click on the spot in here.

94
00:06:40,830 --> 00:06:44,580
Dot dot dot and choose this main activity here.

95
00:06:45,580 --> 00:06:50,830
As you can see here the hierarchical hierarchical parent screen is going to be the main activity.

96
00:06:50,890 --> 00:06:57,240
And here we can specify the package name which is OK by default what is OK and then click on finish.

97
00:06:57,280 --> 00:07:04,540
So now as you can see here at the Android studio he provided us with our settings activity here.

98
00:07:04,900 --> 00:07:08,500
And it also created a certain activity fragment for us.

99
00:07:08,500 --> 00:07:09,070
Right.

100
00:07:09,430 --> 00:07:13,070
And we have also these layouts here.

101
00:07:13,270 --> 00:07:17,280
So we have activity Underland cities that exemplified.

102
00:07:17,430 --> 00:07:23,800
We have content underlined settings that they will find which is going to only provide a fragment for

103
00:07:23,800 --> 00:07:29,970
us as you can see Pracht fragment fragment Underland settings and we have also this fragment underline

104
00:07:30,010 --> 00:07:30,690
settings here.

105
00:07:30,700 --> 00:07:31,720
Right.

106
00:07:31,900 --> 00:07:38,530
So this is our fragment Underland settings and now it's actually double click on this activity Underland

107
00:07:38,530 --> 00:07:39,490
settings here.

108
00:07:39,610 --> 00:07:44,620
Just click on this design tab here at the bottom selectees faluting action button and then press until

109
00:07:44,620 --> 00:07:46,230
it key on your keyboard.

110
00:07:46,640 --> 00:07:50,870
So now let's actually in say the main activity dojo a file here.

111
00:07:50,890 --> 00:07:53,350
And now as you can see here the error is gone.

112
00:07:53,350 --> 00:07:54,130
Right.

113
00:07:54,130 --> 00:07:58,840
So let's actually go inside these settings activity as you can see here.

114
00:07:58,930 --> 00:08:02,530
We have these lines of code that are related to the faluting action button.

115
00:08:02,540 --> 00:08:08,320
So just select this block of code that is related to the fluting action button and then press on delete

116
00:08:08,320 --> 00:08:09,780
key on your keyboard.

117
00:08:10,300 --> 00:08:12,870
And now as you can see here we have this line of code here.

118
00:08:12,880 --> 00:08:18,460
It says Get support action bar that said display home adds up enabled.

119
00:08:18,550 --> 00:08:19,670
So what does this mean.

120
00:08:19,780 --> 00:08:21,720
So now let me show you the emulator.

121
00:08:21,940 --> 00:08:27,100
So here if I actually click on the settings image here as you can see this is our settings activity

122
00:08:27,100 --> 00:08:28,350
right at the top.

123
00:08:28,360 --> 00:08:32,470
You can see this actually this arrow here.

124
00:08:32,680 --> 00:08:37,150
And if I click on it now it's going to actually move to this activity.

125
00:08:37,300 --> 00:08:39,850
So that's the job of this line of code here.

126
00:08:39,910 --> 00:08:41,320
Get support action bar.

127
00:08:41,350 --> 00:08:42,340
So this is action.

128
00:08:42,340 --> 00:08:50,410
But that said display home as OP enabled so it can actually provide this out here for us.

129
00:08:50,410 --> 00:08:54,790
And whenever whenever I actually click on this arrow here as you can see we provided the value true

130
00:08:54,820 --> 00:08:55,340
right.

131
00:08:55,570 --> 00:09:01,290
So if you actually click on these are here now these can actually transition to this activity main activity.

132
00:09:01,420 --> 00:09:02,320
Right.

133
00:09:02,350 --> 00:09:04,060
So hopefully that makes sense.

134
00:09:04,420 --> 00:09:07,990
And now it's actually double click on the settings activity.

135
00:09:08,380 --> 00:09:14,830
Fragment here and now you can see that let's actually double click on this Tapio setting's activity

136
00:09:14,830 --> 00:09:19,350
fragment or Jarba and now you can see this area there you can see that now.

137
00:09:19,390 --> 00:09:21,410
This area is actually wider.

138
00:09:21,790 --> 00:09:28,420
So we have this class savings activity fragment that extends from these Fleischman here as you can see.

139
00:09:28,540 --> 00:09:35,410
So here we don't want to actually directly inherit from this fragment here.

140
00:09:35,410 --> 00:09:39,520
So we want to actually inherit from the France fragment.

141
00:09:39,640 --> 00:09:45,850
As you can see here now if we actually hold the comment on my keyboard and then click on this pre-feminist

142
00:09:45,850 --> 00:09:46,620
fragment here.

143
00:09:46,660 --> 00:09:52,090
So if you are using a Windows machine hold the control key on your keyboard and then click on this preference

144
00:09:52,090 --> 00:09:58,030
for argument as you can see this preference fragment is actually inheriting from this fragment.

145
00:09:58,030 --> 00:09:58,870
Right.

146
00:09:58,990 --> 00:10:01,420
So now let me actually close this file.

147
00:10:01,750 --> 00:10:06,520
And now as you can see here it is sitting actually with the fragment is inheriting from this a preference

148
00:10:06,520 --> 00:10:07,460
fragment.

149
00:10:07,480 --> 00:10:12,520
So now let me delete these lines of code here that are inside of this class.

150
00:10:12,520 --> 00:10:19,120
And now I'm going to pasting some lines of code here and then I'm going to explain to you what's going

151
00:10:19,120 --> 00:10:19,830
on here.

152
00:10:19,930 --> 00:10:24,620
So as you can see here these are the lines of code that I pasted here.

153
00:10:24,640 --> 00:10:27,540
So I actually write it the uncreate Smurfette.

154
00:10:27,580 --> 00:10:33,680
And as you can see this if it actually accepts one argument which is of type Bondel saved instance in

155
00:10:33,730 --> 00:10:34,470
St..

156
00:10:34,810 --> 00:10:38,360
And here you are calling the uncreate of the superclass so stupid.

157
00:10:38,410 --> 00:10:46,240
Uncreate saved instance state and here look at this line of code here which is really important at preferences

158
00:10:46,330 --> 00:10:47,550
from resource.

159
00:10:47,560 --> 00:10:50,400
So let me try to show you the structure of the project.

160
00:10:50,410 --> 00:10:57,670
So just click on View tool windows and then project as you can see we have this ASML folder here.

161
00:10:57,730 --> 00:11:02,000
Right inside this folder we have this ASML folder.

162
00:11:02,170 --> 00:11:05,500
And as you can see we have the squeeze under the link preferences.

163
00:11:05,500 --> 00:11:12,320
So if you actually provided this XML file in order to actually pro-white those settings options.

164
00:11:12,430 --> 00:11:12,910
OK.

165
00:11:13,000 --> 00:11:18,910
In order to actually create two cities items so that the user can actually change the format of the

166
00:11:18,970 --> 00:11:24,600
text of the buttons or the user can actually change the background color of the keys.

167
00:11:24,670 --> 00:11:26,950
So that's the job of this accident.

168
00:11:27,190 --> 00:11:30,680
And if you want to use that FOI for our preferences.

169
00:11:30,910 --> 00:11:33,610
So I actually created this on create Meffert here.

170
00:11:33,610 --> 00:11:39,550
I actually override it this on create method inside the settings active defragment and then I actually

171
00:11:39,550 --> 00:11:46,440
called the Smurfette at preferences from resource and then I pass this value to dismiss that are that

172
00:11:46,520 --> 00:11:52,820
example so it refers to these five dot Q Is Underland preferences right.

173
00:11:52,960 --> 00:11:57,550
So now we can actually get this example fight and show it to the user.

174
00:11:57,670 --> 00:11:58,350
Right.

175
00:11:58,360 --> 00:12:00,990
So let's let's actually go in the setting is activity or jobs.

176
00:12:01,030 --> 00:12:03,840
So now you can see we have these lines of code here.

177
00:12:03,840 --> 00:12:10,220
This is the classic settings activity that extends from app copy of compact activity and the override

178
00:12:10,240 --> 00:12:15,910
that the uncreate Mfat here we called the super class version of this uncreate method and we passed

179
00:12:16,410 --> 00:12:22,150
this argument to the Smurfette and then we called the Smurfette set content view are that lay out that

180
00:12:22,210 --> 00:12:25,100
activity underlying settings right.

181
00:12:25,270 --> 00:12:30,070
So let's actually DoubleClick and lay out what he had as you can see we have this activity under the

182
00:12:30,070 --> 00:12:31,280
line settings here.

183
00:12:31,280 --> 00:12:35,530
So we tried it here and then just double click on it takes time.

184
00:12:35,530 --> 00:12:40,690
Here at the bottom you can see that these are the example codes and we have this include here.

185
00:12:40,690 --> 00:12:46,880
These include tag layout and inside the double codes you can see that it says at sign out so it refers

186
00:12:46,880 --> 00:12:49,820
to this lay out for the slash content.

187
00:12:50,050 --> 00:12:50,950
Settings.

188
00:12:50,980 --> 00:12:56,830
So it's actually it says that we want to include this content underlined settings on this activity underline

189
00:12:56,830 --> 00:12:57,430
settings.

190
00:12:57,520 --> 00:13:00,050
So we have this content Underland settings.

191
00:13:00,170 --> 00:13:03,000
That is as you can see we have this fragment here.

192
00:13:03,160 --> 00:13:09,750
So now it means that we want to use a fragment inside this XML file so that you use that.

193
00:13:09,790 --> 00:13:15,790
Or that the program can actually interact with the fragment as you can see a fragment on the lengths

194
00:13:15,790 --> 00:13:16,460
of things.

195
00:13:16,510 --> 00:13:21,520
And now as you can see we have also this fragment underlined settings that we have these lines of code

196
00:13:21,520 --> 00:13:22,610
here.

197
00:13:22,690 --> 00:13:27,880
And as you can see we want to actually put the squeeze underline preferences that exemplified on this

198
00:13:27,880 --> 00:13:29,610
fragment underline settings.

199
00:13:29,640 --> 00:13:36,160
So inside the settings activity fragment you can see that we are right at the uncreate Merfeld right.

200
00:13:36,760 --> 00:13:44,320
And then we called this Myford at preferences from resource are that ASML that these underline preferences.

201
00:13:44,320 --> 00:13:47,900
So now let's actually build on our project and see what happens.

