Come back in this video, we are going to change our culture a little bit and prepare our first app
to actually do what we wanted to do, and that is to not display Helloworld, but actually our name.
So therefore, let's get started and look at what the code does for us.
So let's go to the main activity.
You can either go to it from here and if you by accident closed it, for example, you can still find
it in your app.
Java, then the name of your package and then main activity.
So can see this is the name of the package that we have selected to when we created the project.
And you can also find that package name up here.
So you wrote that artist up my first app.
This just says that this file.
All of the code that is in here belongs to the package of EU, the tutorials that my first app.
Then you find this import keyword and import keyboard has three dots in it, which means there is something
behind it so you can click on it and then this pops up.
You can see here Android Acts App Compered Dot App Dot app activity, which is a library or a namespace,
however you want to call it.
Both words are fine, which basically means that there is a lot of code behind it, and it allows us
to use its functionality.
So if we delete this line of code, then suddenly our program starts to not work anymore.
So we get an error you can see here.
It's underlined here does main activity, so it doesn't understand what this override method does because,
well, we never had set it up.
So that's something that is set up in this app combat activity, which basically is a lot of code that
somebody else wrote for us and we can now reuse in order to not have to write that code manually ourself.
So we should be thankful to them because they really save us a lot of time.
So thanks a lot for doing that.
Now we are using this app activity here again, you can see, and that is only possible because we have
this input now.
The same goes for this bundle.
Here you can see Save the Instance bundle what we're using this bundle code in our class main activity
as well.
So that's why we have these imports and we're going to add more imports later on, which will then allow
us to use different kinds of codes and functionality, which is very powerful.
If you want to understand more what's behind this app combat activity, you can just hold your command
key or control key and then click on to the name here and you will find that it opens up this declaration.
For this file, you can see it's called App Combat Activity that Java, so it's a Java file, it's not
a cut and file.
You can also see that byte structure, so the code is slightly differently written, so you have to
access modifiers everywhere.
You don't even need to understand what that is at this point.
So you can see there are hundreds of lines of code basically allowing us to use them.
And then the same goes for this bundle.
You can just click on to it and then you can well access it to make changes to it, but I'm not going
to do that for now.
So then this is the important part.
This is basically where our own code starts.
So we have our main activity, which is a class.
So then we have this class keyword and we're going to look deeper into what a class is later on.
But generally it's going to be the container for our code.
It's going to hold our code and it will allow us to execute some code.
So we call this class main activity and it has this colon here, then Epcot combat activity, which
basically just means that it inherits from app competitively team.
And we're going to see what inheritance is later on once we get to object oriented programming.
It would lead way too far for now.
What's really important is that we have this on create method, which will be called once our main activity
is going to be created.
And by the way, an activity is just a screen.
So if you have multiple screens in your application, for example, the login screen and then the profile
screen and so forth, all of those would be different activities.
And we're going to create multiple different activities later on when we create more complex applications.
But that's what you just need to remember.
For now, activity equals screen.
And then we have this override function on create.
So this is a fun, which means a function.
This is not about having fun or something like that, even though you can have fun with functions,
but this is our function which is overridden on create.
So basically, it just means there is some on method inside of the combat activity and we are overwriting
it with our own code.
So what you're saying, OK, we're going to run our own code.
Then there is a bundle passed here and that's something we're not going to cover for now.
And the super method is called so super on create, for instance, which just means that whatever combat
activity wants to execute by default in aggregate is being executed.
And then comes the interesting part.
That's where we.
Actually can make changes, so this is going to be the content view which actually sets the content
of the View.
Who would have guessed it?
And to what we're saying here is please set the content of our layout activity main.
And where do you find this file?
You find it under our dot layout that activity, mate.
So where is that?
Well, our stance for resources.
So if you go over here, you will find this press folder not to generate it one, but the other one.
And then you will find a folder called layout.
And that's exactly where our activity main file is.
So we're just saying, OK, set the view to have the contents of our activity main, which means that
this is the XML file which will be actually displayed on our application.
So let's change that up a little bit.
First of all, click on this helloworld here.
You can either click on it from the componentry here.
On the left hand side, just click on this text view, or you can access it directly via the designer
view.
So here, let's click on this helloworld and then on the right hand side in the attributes, you can
go to declared attributes.
OK, so there are a bunch of different settings.
You can go to common attributes, two declared attributes and so forth.
So I'm just going to go over to the declared attributes and we can declare the Helloworld to display
something else.
So here I'm just going to say hello, Dennis and press enter.
And you can see that now the text should say Hello, Dennis.
We'll get a little exclamation mark, but we're going to ignore that for now, it would go too far at
this point.
We're going to see what that means later on.
But now it just says, Hello, Dennis.
But I'm not very happy with that.
I would like this to look a little different.
I would like it to be bigger.
So in order to change that, you can go over to your common attributes and you can go to text appearance.
And here you can change, for example, the font family if you want it to look differently.
Here there are serif, black, medium light and so forth.
You could change the typeface.
But what I'm interested in is the text size, so I'm going to change that to 25 ESP, for example,
ESP here by stands for scale independent pixels.
Which just means that it's going to look more or less the same, no matter which device you are using,
because pixels are different on each device.
So let's say you have a big screen, then each pixel is going to be look bigger, right?
But SP, what it tries to do is it tries to make it independent of the size of the screen or the amount
of pixels that the screen has.
This tech should always look the same, or more or less the same.
We'll never be exactly the same, but here at the top you can even select the device and you can see
the DPI.
So now if we look at it on a phone that has a different dpi, sort of, let's say, five hundred sixty,
for example, you can see the text still looks more or less the same.
OK.
So I'm going to go back to Pixel four, which is the device that we're using here at the top.
So that's how the text is going to look like now.
Let's run the application, so click on this button here at the top and see what's going to happen.
And there we are, my first EP, says Hello, Dennis.
Of course it shouldn't say hello, Dennis, in your case, I would like you to enter your own name here.
Now you can, of course, also write something entirely differently.
Maybe even in your native language, if English isn't your native language, then just change that to
whatever text you want to display and try it once again with a common attributes.
Here, for example, you could change to color as well.
If you don't want to use black, you could use red, for example.
I really love the color red, so change that.
Rerun the application and then go over here and you will see that it says hello, diners in red now.
OK, so that's pretty much it for this video, we have set up our first on changes when as to what the
main activity does and what all of this stuff more or less does, even though we are going to go into
a lot more depth into what is happening here.
So no worries.
If you don't understand what's up here, the only thing that you needed to understand is that there
are packages you can import different libraries that allow you to then use their code.
And we have this container, which basically is going to take care of what we can see on the screen
by setting the XML file that we have here that we can then edit.
And by the way, if you want to jump through this file directly, you can hold the control key.
Click on it and it will jump to this activity.
Main example and just a very quick one.
We're not going to change anything there, but this design here is just one way of looking at this.
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
of that means later on in the course.
But you will probably already see it, says Halo, then is here.
It says that there is a certain text color, which is this red, and you see that there's a certain
text size that we have defined and that is basically representing what we see right here.
All right, so see you in the next video where we're going to create a people counter app.