1
00:00:01,280 --> 00:00:06,890
Come back in this video, we are going to change our culture a little bit and prepare our first app

2
00:00:07,010 --> 00:00:12,680
to actually do what we wanted to do, and that is to not display Helloworld, but actually our name.

3
00:00:13,130 --> 00:00:17,180
So therefore, let's get started and look at what the code does for us.

4
00:00:17,480 --> 00:00:19,310
So let's go to the main activity.

5
00:00:19,320 --> 00:00:24,590
You can either go to it from here and if you by accident closed it, for example, you can still find

6
00:00:24,590 --> 00:00:25,670
it in your app.

7
00:00:25,940 --> 00:00:30,710
Java, then the name of your package and then main activity.

8
00:00:31,310 --> 00:00:36,230
So can see this is the name of the package that we have selected to when we created the project.

9
00:00:36,590 --> 00:00:39,150
And you can also find that package name up here.

10
00:00:39,200 --> 00:00:41,270
So you wrote that artist up my first app.

11
00:00:41,600 --> 00:00:43,550
This just says that this file.

12
00:00:43,640 --> 00:00:48,470
All of the code that is in here belongs to the package of EU, the tutorials that my first app.

13
00:00:49,220 --> 00:00:54,590
Then you find this import keyword and import keyboard has three dots in it, which means there is something

14
00:00:54,590 --> 00:00:57,950
behind it so you can click on it and then this pops up.

15
00:00:58,220 --> 00:01:06,880
You can see here Android Acts App Compered Dot App Dot app activity, which is a library or a namespace,

16
00:01:06,890 --> 00:01:08,090
however you want to call it.

17
00:01:08,300 --> 00:01:15,140
Both words are fine, which basically means that there is a lot of code behind it, and it allows us

18
00:01:15,140 --> 00:01:16,760
to use its functionality.

19
00:01:17,180 --> 00:01:24,650
So if we delete this line of code, then suddenly our program starts to not work anymore.

20
00:01:24,770 --> 00:01:26,360
So we get an error you can see here.

21
00:01:26,360 --> 00:01:33,560
It's underlined here does main activity, so it doesn't understand what this override method does because,

22
00:01:33,560 --> 00:01:36,110
well, we never had set it up.

23
00:01:36,290 --> 00:01:41,450
So that's something that is set up in this app combat activity, which basically is a lot of code that

24
00:01:41,450 --> 00:01:47,000
somebody else wrote for us and we can now reuse in order to not have to write that code manually ourself.

25
00:01:47,390 --> 00:01:51,140
So we should be thankful to them because they really save us a lot of time.

26
00:01:51,170 --> 00:01:52,490
So thanks a lot for doing that.

27
00:01:53,090 --> 00:01:58,520
Now we are using this app activity here again, you can see, and that is only possible because we have

28
00:01:58,520 --> 00:01:59,800
this input now.

29
00:01:59,810 --> 00:02:01,400
The same goes for this bundle.

30
00:02:01,400 --> 00:02:08,210
Here you can see Save the Instance bundle what we're using this bundle code in our class main activity

31
00:02:08,210 --> 00:02:08,660
as well.

32
00:02:08,900 --> 00:02:14,870
So that's why we have these imports and we're going to add more imports later on, which will then allow

33
00:02:14,870 --> 00:02:20,750
us to use different kinds of codes and functionality, which is very powerful.

34
00:02:21,170 --> 00:02:26,390
If you want to understand more what's behind this app combat activity, you can just hold your command

35
00:02:26,390 --> 00:02:34,580
key or control key and then click on to the name here and you will find that it opens up this declaration.

36
00:02:34,580 --> 00:02:39,650
For this file, you can see it's called App Combat Activity that Java, so it's a Java file, it's not

37
00:02:39,650 --> 00:02:40,610
a cut and file.

38
00:02:40,970 --> 00:02:46,610
You can also see that byte structure, so the code is slightly differently written, so you have to

39
00:02:46,610 --> 00:02:48,260
access modifiers everywhere.

40
00:02:48,500 --> 00:02:50,990
You don't even need to understand what that is at this point.

41
00:02:50,990 --> 00:02:54,860
So you can see there are hundreds of lines of code basically allowing us to use them.

42
00:02:55,100 --> 00:02:56,840
And then the same goes for this bundle.

43
00:02:56,990 --> 00:03:02,030
You can just click on to it and then you can well access it to make changes to it, but I'm not going

44
00:03:02,030 --> 00:03:03,020
to do that for now.

45
00:03:03,560 --> 00:03:05,570
So then this is the important part.

46
00:03:05,660 --> 00:03:08,660
This is basically where our own code starts.

47
00:03:08,780 --> 00:03:11,750
So we have our main activity, which is a class.

48
00:03:11,870 --> 00:03:16,910
So then we have this class keyword and we're going to look deeper into what a class is later on.

49
00:03:16,910 --> 00:03:21,200
But generally it's going to be the container for our code.

50
00:03:21,320 --> 00:03:26,330
It's going to hold our code and it will allow us to execute some code.

51
00:03:26,930 --> 00:03:33,890
So we call this class main activity and it has this colon here, then Epcot combat activity, which

52
00:03:33,890 --> 00:03:37,330
basically just means that it inherits from app competitively team.

53
00:03:37,340 --> 00:03:41,900
And we're going to see what inheritance is later on once we get to object oriented programming.

54
00:03:42,200 --> 00:03:43,730
It would lead way too far for now.

55
00:03:44,030 --> 00:03:49,610
What's really important is that we have this on create method, which will be called once our main activity

56
00:03:49,910 --> 00:03:51,380
is going to be created.

57
00:03:51,740 --> 00:03:54,710
And by the way, an activity is just a screen.

58
00:03:54,950 --> 00:04:00,560
So if you have multiple screens in your application, for example, the login screen and then the profile

59
00:04:00,560 --> 00:04:04,550
screen and so forth, all of those would be different activities.

60
00:04:05,210 --> 00:04:11,210
And we're going to create multiple different activities later on when we create more complex applications.

61
00:04:11,450 --> 00:04:13,130
But that's what you just need to remember.

62
00:04:13,130 --> 00:04:15,050
For now, activity equals screen.

63
00:04:15,620 --> 00:04:19,040
And then we have this override function on create.

64
00:04:19,399 --> 00:04:21,589
So this is a fun, which means a function.

65
00:04:21,620 --> 00:04:25,430
This is not about having fun or something like that, even though you can have fun with functions,

66
00:04:25,670 --> 00:04:29,630
but this is our function which is overridden on create.

67
00:04:29,630 --> 00:04:37,130
So basically, it just means there is some on method inside of the combat activity and we are overwriting

68
00:04:37,130 --> 00:04:38,480
it with our own code.

69
00:04:39,260 --> 00:04:41,930
So what you're saying, OK, we're going to run our own code.

70
00:04:42,320 --> 00:04:46,400
Then there is a bundle passed here and that's something we're not going to cover for now.

71
00:04:46,760 --> 00:04:52,450
And the super method is called so super on create, for instance, which just means that whatever combat

72
00:04:52,520 --> 00:04:57,230
activity wants to execute by default in aggregate is being executed.

73
00:04:57,650 --> 00:04:59,130
And then comes the interesting part.

74
00:04:59,150 --> 00:05:00,440
That's where we.

75
00:05:00,580 --> 00:05:07,000
Actually can make changes, so this is going to be the content view which actually sets the content

76
00:05:07,150 --> 00:05:07,840
of the View.

77
00:05:08,140 --> 00:05:09,100
Who would have guessed it?

78
00:05:09,400 --> 00:05:15,690
And to what we're saying here is please set the content of our layout activity main.

79
00:05:16,150 --> 00:05:17,540
And where do you find this file?

80
00:05:17,560 --> 00:05:20,560
You find it under our dot layout that activity, mate.

81
00:05:21,040 --> 00:05:22,030
So where is that?

82
00:05:22,270 --> 00:05:24,820
Well, our stance for resources.

83
00:05:25,270 --> 00:05:30,940
So if you go over here, you will find this press folder not to generate it one, but the other one.

84
00:05:31,420 --> 00:05:33,700
And then you will find a folder called layout.

85
00:05:34,000 --> 00:05:36,970
And that's exactly where our activity main file is.

86
00:05:37,360 --> 00:05:42,820
So we're just saying, OK, set the view to have the contents of our activity main, which means that

87
00:05:42,820 --> 00:05:46,990
this is the XML file which will be actually displayed on our application.

88
00:05:47,350 --> 00:05:49,030
So let's change that up a little bit.

89
00:05:49,270 --> 00:05:51,620
First of all, click on this helloworld here.

90
00:05:51,700 --> 00:05:54,430
You can either click on it from the componentry here.

91
00:05:54,430 --> 00:05:59,830
On the left hand side, just click on this text view, or you can access it directly via the designer

92
00:05:59,830 --> 00:06:00,100
view.

93
00:06:00,670 --> 00:06:06,430
So here, let's click on this helloworld and then on the right hand side in the attributes, you can

94
00:06:06,820 --> 00:06:09,090
go to declared attributes.

95
00:06:09,100 --> 00:06:11,800
OK, so there are a bunch of different settings.

96
00:06:11,800 --> 00:06:16,030
You can go to common attributes, two declared attributes and so forth.

97
00:06:16,270 --> 00:06:23,260
So I'm just going to go over to the declared attributes and we can declare the Helloworld to display

98
00:06:23,260 --> 00:06:23,890
something else.

99
00:06:24,070 --> 00:06:27,610
So here I'm just going to say hello, Dennis and press enter.

100
00:06:28,180 --> 00:06:31,720
And you can see that now the text should say Hello, Dennis.

101
00:06:32,140 --> 00:06:36,700
We'll get a little exclamation mark, but we're going to ignore that for now, it would go too far at

102
00:06:36,700 --> 00:06:37,220
this point.

103
00:06:37,300 --> 00:06:38,920
We're going to see what that means later on.

104
00:06:39,580 --> 00:06:41,560
But now it just says, Hello, Dennis.

105
00:06:42,070 --> 00:06:43,300
But I'm not very happy with that.

106
00:06:43,300 --> 00:06:45,690
I would like this to look a little different.

107
00:06:45,700 --> 00:06:47,200
I would like it to be bigger.

108
00:06:47,920 --> 00:06:55,150
So in order to change that, you can go over to your common attributes and you can go to text appearance.

109
00:06:55,720 --> 00:06:59,830
And here you can change, for example, the font family if you want it to look differently.

110
00:07:00,430 --> 00:07:03,580
Here there are serif, black, medium light and so forth.

111
00:07:04,270 --> 00:07:05,650
You could change the typeface.

112
00:07:06,040 --> 00:07:12,070
But what I'm interested in is the text size, so I'm going to change that to 25 ESP, for example,

113
00:07:12,580 --> 00:07:16,450
ESP here by stands for scale independent pixels.

114
00:07:18,300 --> 00:07:25,070
Which just means that it's going to look more or less the same, no matter which device you are using,

115
00:07:25,530 --> 00:07:29,040
because pixels are different on each device.

116
00:07:29,040 --> 00:07:35,340
So let's say you have a big screen, then each pixel is going to be look bigger, right?

117
00:07:35,730 --> 00:07:42,810
But SP, what it tries to do is it tries to make it independent of the size of the screen or the amount

118
00:07:42,810 --> 00:07:44,460
of pixels that the screen has.

119
00:07:44,700 --> 00:07:48,040
This tech should always look the same, or more or less the same.

120
00:07:48,060 --> 00:07:53,100
We'll never be exactly the same, but here at the top you can even select the device and you can see

121
00:07:53,100 --> 00:07:53,900
the DPI.

122
00:07:54,150 --> 00:08:01,110
So now if we look at it on a phone that has a different dpi, sort of, let's say, five hundred sixty,

123
00:08:01,110 --> 00:08:04,530
for example, you can see the text still looks more or less the same.

124
00:08:05,250 --> 00:08:05,690
OK.

125
00:08:05,910 --> 00:08:10,950
So I'm going to go back to Pixel four, which is the device that we're using here at the top.

126
00:08:11,220 --> 00:08:13,740
So that's how the text is going to look like now.

127
00:08:13,740 --> 00:08:19,020
Let's run the application, so click on this button here at the top and see what's going to happen.

128
00:08:20,610 --> 00:08:23,250
And there we are, my first EP, says Hello, Dennis.

129
00:08:23,530 --> 00:08:27,690
Of course it shouldn't say hello, Dennis, in your case, I would like you to enter your own name here.

130
00:08:28,290 --> 00:08:31,810
Now you can, of course, also write something entirely differently.

131
00:08:31,830 --> 00:08:37,530
Maybe even in your native language, if English isn't your native language, then just change that to

132
00:08:37,530 --> 00:08:42,330
whatever text you want to display and try it once again with a common attributes.

133
00:08:42,330 --> 00:08:45,260
Here, for example, you could change to color as well.

134
00:08:45,270 --> 00:08:48,670
If you don't want to use black, you could use red, for example.

135
00:08:48,700 --> 00:08:51,720
I really love the color red, so change that.

136
00:08:51,960 --> 00:08:57,750
Rerun the application and then go over here and you will see that it says hello, diners in red now.

137
00:08:59,080 --> 00:09:05,950
OK, so that's pretty much it for this video, we have set up our first on changes when as to what the

138
00:09:05,950 --> 00:09:12,370
main activity does and what all of this stuff more or less does, even though we are going to go into

139
00:09:12,370 --> 00:09:14,830
a lot more depth into what is happening here.

140
00:09:14,830 --> 00:09:15,670
So no worries.

141
00:09:15,670 --> 00:09:20,110
If you don't understand what's up here, the only thing that you needed to understand is that there

142
00:09:20,110 --> 00:09:26,590
are packages you can import different libraries that allow you to then use their code.

143
00:09:26,740 --> 00:09:32,620
And we have this container, which basically is going to take care of what we can see on the screen

144
00:09:32,620 --> 00:09:37,570
by setting the XML file that we have here that we can then edit.

145
00:09:37,570 --> 00:09:41,770
And by the way, if you want to jump through this file directly, you can hold the control key.

146
00:09:41,770 --> 00:09:44,080
Click on it and it will jump to this activity.

147
00:09:44,080 --> 00:09:46,780
Main example and just a very quick one.

148
00:09:46,780 --> 00:09:51,700
We're not going to change anything there, but this design here is just one way of looking at this.

149
00:09:52,040 --> 00:09:57,490
We're going to work a lot with the code, and this is how the code is and we're going to see what all

150
00:09:57,490 --> 00:09:59,200
of that means later on in the course.

151
00:10:00,130 --> 00:10:02,870
But you will probably already see it, says Halo, then is here.

152
00:10:02,890 --> 00:10:07,360
It says that there is a certain text color, which is this red, and you see that there's a certain

153
00:10:07,360 --> 00:10:13,810
text size that we have defined and that is basically representing what we see right here.

154
00:10:16,150 --> 00:10:20,350
All right, so see you in the next video where we're going to create a people counter app.

