Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Hello, everyone, and welcome to the complete\n
is Mason. I'm a professional Android app developer.\n
course. Before starting the course, let's\n
is about 15 hours. And by watching it, you're\n
But it is impossible to cover everything in\n
version of this course, which is about 60\n
that you need for a successful career in Android\n
course by clicking on the link down below\n
cover in this video. In this 15 hours, you\n
that even if you don't have any prior experience\n
We will cover everything in the course in\n
up the environment that you need for Android\n
Java Development Kit, Android Studio software\n
and emulator for testing your applications.\n
first section, you will create a small application\n
and each piece in an Android application.\n
learn Java language Java is the most popular\n
in this section, we will take a deep look\n
and operators, loops and conditional statements,\n
and trading, handling exceptions Singleton\n
about object oriented programming in Java.\n
inner classes and abstract classes, inheritance\n
end this section with a challenge. So to make\n
talked about. In the next section, you will\n
about how to design modern layouts for your\n
about things like buttons and text views,\n
fonts showing a list of items with ListView\n
bars and card views, adding animations to\n
we will talk about material design in Android.\n
a challenge so to make sure that you have\n
designing user interfaces, you have the ability\n
section of this course we will create one\n
combine all of our knowledge about Android\n
together in this section beside practicing\n
learn about a lot more topics. For instance,\n
with shared preferences. And also you will\n
application. And of course a lot more. You\n
portfolio if you want. We are going to set\n
create Android applications. We are going\n
going to install Java Development Kit or as\n
going to install Android Studio. And after\n
device in order to test our Android applications.\n
JDK and Android Studio. Let's also see where\n
search for Java JDK, and a link from Oracle\n
the Oracle web page is probably our needed\n
and install JDK version eight, it's going\n
down in here. First of all we need to agree\n
depending on your operating system, you can\n
so I'm going to download and install this\n
this x86 or x 64, you can right click on your\n
In here you can see the architecture of your\n
Depending on that select one of these two\n
download should be started. Sometimes like\n
account. Let's do that creating an Oracle\n
Okay, let's select Sign in. And as you can\n
the canceling here because I have downloaded\n
going to be a really simple installation process.\n
Once again next. Once again, let's click on\n
installed JDK. Let's click on this plus, if\n
Java JDK successfully, you can always go to\n
and typing cmd. In here, you can type Java\n
some information about the version of Java\n
and higher, we are good to go. Let's close\n
download Android Studio. For that we can go\n
During the course, we will come back to this\n
website for Android developers. Okay, for\n
Andrew the studio tab. And from here, you\n
see your version of operating system, you\n
here, I'm just going to click on the download,\n
to agree to the terms and conditions. And\n
Once again, I'm going to select to cancel\n
Android Studio. After the download is finished,\n
to be a simple installation process. Let's\n
Android virtual device. Let's select Next\n
Android Studio. Notice that installing Android\n
sometimes might take something like 20 or\n
least 20 gigabytes on the drive that you are\n
that. Let's select Next, and install. After\n
this next. And let's start our Android Studio.\n
I have in here. Basically, these are the recent\n
Studio installed on my system previously,\n
you this list would be empty. Also along the\n
see some windows is about selecting a theme\n
I have installed Android Studio previously\n
on your preferences, select one just if you\n
that because we are going to install everything\n
can come to this configuring here. And you\n
software development kit. And for developing\n
at least one SDK. Once again, as you can see,\n
an Android nine API's both for you this list\n
checked. First of all, let's check this show\n
details for every SDK. By the time I'm recording\n
is Android 10 or aka level 29. To be precise,\n
version. But sometimes there might be some\n
installing those because those can be buggy.\n
channel. So make sure to install the latest\n
the complete SDK. But I don't suggest that\n
consuming. And these can occupy a lot of the\n
things in here is first of all Android SDK\n
is. So the first one, also the sources for\n
I suggest that depending on the architecture\n
of atom mine was 64 architecture. So I'm going\n
with different Google API's. For example,\n
YouTube API's, check one of these, for example,\n
one of these two Google API versions. This\n
system, and return or API level 29. But if\n
SDK versions. Basically, this SDK versions\n
Are you going to run and test your applications\n
to run our application On a virtual device,\n
multiple SDKs can be memory consuming and\n
the resources, I suggest that you at least\n
this API level 29. Because there were a lot\n
structure also installed API level 28, down\n
that, level, 21, and also 19. Because in this\n
And I'm just saying this because of my experience\n
have the proper resources, selecting one of\n
what you need in here, just click on this\n
connection because it's going to download\n
here you can see a dialog that will show you\n
going to be downloaded and also the size of\n
and our download should be started. I'm going\n
is finished. After the downloading and installing\n
Before it's finished, just click on this finish.\n
Okay, we have successfully installed at least\n
let's see what we need from here. First of\n
install one of these Android SDK build tools,\n
As you can see, mine is installed in here\n
Also down in here, you need to install Android\n
to update that. The next two things that are\n
SDK tools, make sure to select those two.\n
for Android SDK. This option is not necessary,\n
journey in Android app development. Later\n
will help us a lot when we want to debug something\n
suggest to install these documentations as\n
but I suggest to install is this hexam installer,\n
of your emulator. The native emulator in Android\n
have a low memory Ram. For that reason, I\n
But there is one thing that I need to mention\n
problem with this hexam installer, I've seen\n
them successfully. This hex m cannot be installed\n
of your CPU, this XM might not be installed.\n
CPUs that they have a special option in the\n
accelerator. If that's not enabled, you may\n
well. And also if for any reason you couldn't\n
accelerator. And also for that matter, the\n
to worry there is another way as well. Besides\n
external emulators as well for example, the\n
is called genymotion. In here, I'm not going\n
genymotion in the description of this video.\n
install and test your applications on the\n
course we will see that how we can install\n
Okay, after selecting everything from here,\n
we are seeing the download the information\n
Once again. I'm going to skip the video in\n
again When the download and installing is\n
have successfully installed SDK platforms\n
let's switch to this appearance in here. From\n
that you want. For example, you can change\n
we have this high contrast theme. The intelligent\n
with that because it's good for recording\n
for the fonts of your Windows is from here.\n
I'm not going to do that. Also then in here,\n
presentation mode. If you want to change the\n
in here, I believe it's in this editor tab\n
is 18, you can increase or decrease that if\n
let's minimize this editor. I have another\n
appearance inside the system settings inside\n
being checked from a stable channel. We have\n
betha channels as well make sure that you\n
Okay, that's it for installing SDK, we will\n
on. Let's select OK. OK, now it's time to\n
can once again select this configure this\n
stands for Android virtual device. As you\n
in here pixel two and pixel three, this list\n
Android Studio installed on my system, I can\n
in order to create a new virtual device. First\n
the hardware by selecting this new hardware\n
you can select that if it's a phone or tablet,\n
Also then in here you can specify some ram\n
I'm not going to create my customized device.\n
devices. As you can see, I have pixel two\n
device from here. Also from this left panel,\n
and tablets. Let's select one device from\n
Let's just select this pixel Excel, select\n
the Android version that is going to be installed\n
q or API level 29 on this device, so we need\n
once again, I think it's going to be a large\n
here until the download is finished. Yes,\n
installing is finished just click on Finish.\n
you might not see the version of API that\n
you can always refer to this list. After that,\n
third tab. But we are going to install Android\n
we can customize our device. For example,\n
also change the default orientation. For example,\n
its portrait. In this Show advanced settings,\n
you can change the camera, the network. Also\n
and SD card and all sorts of customization.\n
just going to click on this finish. And as\n
on our device. Okay, let's close this window.\n
off this video. In this video, we have installed\n
After that we have installed SDK and we have\n
And after everything we have installed a new\nvirtual device.
We are going to create our first application\n
selecting this start a new Android Studio\n
can see some templates. These templates are\n
codes written to some level. For example,\n
have a small button and also a menu above\n
for example, a template for Google Maps, we\n
worry about all of these because we will learn\n
later on. Even we select this ad no activity\n
and they have provided us these templates.\n
word activity Don't worry about this activity\n
I said that we are going to have an entire\n
and fragments. But for now you can think of\n
application. For example, if your application\n
those pages, this definition is not accurate,\n
we can think of an activity as a page of our\n
going to save it this empty activity, which\n
some files for us. But if you want to save\n
Once again, later on, we will see that how\n
Okay, let's select empty activity. And let's\n
information about our application. For example,\n
change the name of my application to let's\n
to name their first project, I level just\n
the package name for your application. This\n
that is being released into the world. later\n
to play store, your application will be identified\n
here is to provide the name of your website\n
maker.org. So my package name is or dot maker\n
you don't have any website, if you don't,\n
Let's say comm dot example dot the name of\n
going to use that in here, I'm going to say\n
be unique to every application. After that,\n
to save your project. If you want, you can\n
in here and select the path but in here, I'm\n
select the language that you're going to work\n
with Java language, and also kotlin language.\n
Java. But if you want, I am currently recording\n
with kotlin. Feel free to check that if you\n
that, you need to define a minimum API level.\n
how many older Android devices can install\n
on this drop down in here, you can see the\n
minimum API level that I can select these\n
10. To be precise, there is a balance in here.\n
high, you can work with a lot of newer functionalities\n
to install your Android applications. For\n
the latest version, only less than 1% of the\n
something like 19, we can see that 95% of\n
you as the developer should decide this balance\n
stay with API level 19 for most of our projects,\n
is a good number. Leave this check empty for\n
since few months ago, we will talk about it\n
let's create our first project. If it's the\n
applications, this process can be very slow\n
some stuff, for example, the gradle file from\n
can be slow if it's the first time that you\n
in here that is noticeable is that Android\n
activity main dot XML file, and this main\n
because we have selected that empty activity\n
Inside each of these files. There are some\n
codes if we don't select that empty activity.\n
codes written to some level. The other thing\n
build painting here will show the progress\n
you want to run your Android application,\n
will be working in our entire course. Whether\n
here will show the progress of building your\n
it for now. And let's talk about all the other\n
all, let's talk about this project thing here,\n
here, we have multiple options. For example,\n
option view exactly shows the structure of\n
maximize every folder. If you want to have\n
you can go to App folder inside the sources.\n
you can see that we have a folder in here,\n
This is the exact hierarchy of files on our\n
you can right click on the name of your project\n
here, it will open the Explorer on your Windows,\n
don't worry about the others inside this project.\n
this app folder. Inside this app folder, we\n
org, may code HelloWorld. And this is the\n
project view will show the exact hierarchy\n
another view in here and that's called Android\n
for the most of this course, because it's\n
can see, we have this app folder. And inside\n
package name. And inside that we have this\n
easy for eyes to follow different files. Also,\n
scripts down in here as well. Before I talk\n
about the structure of every Android application.\n
at least two different kinds of files, the\n
of your application. The layout files in Android\n
main dot XML file. If you click on that, you\n
now it has only one simple text. The other\n
file. If you are developing in kotlin language,\n
file in most cases will define the logic of\n
if you click on a button, or what to do with\n
in the Java or kotlin files. Beside the layout\n
There might be some other files, for example,\n
files as well. Those will be inside this Resources\n
Right now we have an icon for our application,\n
images or other files can be put inside this\n
Resources folder is for the static variables\n
are the three main components of every Android\n
Java file, and also we have the static files.\n
the manifest folder. This manifest file Vila\n
application. For example, you can see the\n
can see the name of your application, which\n
properties or features about your application.\n
on in the course. But for now, let's close\n
every Android application. But for example,\n
from the Play Store, you will see that we\n
final application that will be released, how\n
in that case, this Gradle tooling here is\n
that will combine all of these files and other\n
matter if you want to release your application\n
an emulator, you are going to need Gradle\n
with The other use of Gradle is that if you\n
as well, for example, if you want to use YouTube\n
inside this built up gradle file down in here,\n
download the code for YouTube video player,\n
player code to your project. And after that,\n
that will handle the combination of every\n
an APK file, we will talk about different\n
let's close all of these extra files. Okay,\n
or maximize this pain from here. Let's minimize\n
in Android Studio. Then in here, you have\n
to do is very helpful when you are creating\n
to those are some works that you don't want\n
those works. For example, inside this main\n
I can say to do, let's say complete
this. It's just for the developers to remind\n
later on. As you can see this to do has been\n
want, you can check that it says that it's\n
talk about how we can define to dues and also\n
the other pains. The other one is this terminal\n
prompt in Windows or let's say terminal in\n
working with something like ADB or Android\n
of ADB in our projects. Also, it's very useful\n
worked extensively with this terminal in the\n
new tool here we have seen it when we have\n
of every application when it's going to be\n
problem when we build our project. And from\n
After that we have this logcat in here, it's\n
to debug our Android applications. In fact,\n
at Okay, let's minimize all of these for now.\n
File, Edit view and all of these, we will\n
but it's impossible to work with all of them.\n
in here. When you create your first application,\n
rendering warning or some other kind of warning,\n
wrong with your application, you just need\n
come to this build option in here and make\n
some errors at the first time that you create\n
of Android Studio can be buggy. And creating\n
problem. Also, there is another option from\n
and reopen it that can be useful or in some\n
and restart Android Studio. So if you get\n
three different ways in order to overcome\n
that has been added to Android Studio recently\n
Android profiler. Let's add that to this pane.\n
to this view to Windows and profiler, it's\n
that your application is using, for example,\n
is using, or even the amount of network that\n
application, we can track the live amount\n
is going to use. Let's run our application\n
by clicking on this green triangle from here,\n
app that you're working. And also beside that\n
video we have created a virtual device and\n
available. I'm going to run my application\n
let's just run. If we click on this building\n
that even if you are going to debug your application,\n
at the production process, you can check the\n
this emulator has been opened. And we will\n
from down in here, you can see the current\n
now it has created or built my application\n
to turn on. Also, if you check this logcat\n
of things going on in here. We will be using\n
for different debugging purposes. Let's minimize\n
will see the live tracks of different resources\n
our emulator. Right now we have this simple\n
called hello world. And if you want, you can\n
resources that your application is
using, it's going to be helpful when you're\n
is using. Let's minimize that for now. If\n
this red button here, you can stop it. And\n
By long pressing this turn off button, you\n
shut down. As you can see, we are getting\n
not important. But if you want to check them,\n
that happens since we click on this green\n
let's minimize that. And let's switch back\n
have a lot of options in here as well. Right\n
application. This white one is called the\n
view. There are some slight differences between\n
item inside your activity that might not be\n
keep track of that inside the blueprint view.\n
view because we are not going to work with\n
you can click on this stack icon. And you\n
and maximize that by pressing this plus button.\n
elements different user interface or UI elements.\n
your application, you can simply drag it like\n
application. As you can see right now because\n
attributes. At the right panel, we have a\n
element. The most important one is this ID\n
your element in which we will use it in order\n
from inside of Java file. Later on, we will\n
you can see that we have different attributes\n
If you want to check the list of all of the\n
all attributes. And you can see that there\n
with different UI elements in the UI session\n
now, after the Java session we will be talking\n
Also, when you are inside your XML file, you\n
view is this view that we are working right\n
can see the exact value of every UI element\n
you are a web developer, you know the concept\n
language. markup languages are just for defining\n
example, a button or text view, you can see\n
but that the don't know anything about them\n
in the force. So there are two ways of defining\n
for example, a button to your design view,\n
can see that we have a button in here, we\n
press Delete, and that button will be deleted,\n
Also, if you don't have this preview enabled,\n
Ctrl Z in order to get back our button. And\n
going to define an ID for this Hello text\n
going to identify that and I'm going to work\n
can see the list of attributes. At the top,\n
TextView. Also, if you don't know the difference\n
these don't be very TextView is just a fancy\n
the ID whatever you want. For example, in\n
that there are some conventions in here, you\n
an ID also beside that you can't use some\n
sign. The other convention in here is that\n
For example, this team here is learn cases.\n
first letter of the second word. in capital\n
there are some just basic conventions among\n
an ID for this hello world. If we switch back\n
see that for this TextView, an attribute has\n
what you do inside your TextView or design\n
you can see, right now we have some warning\n
button is not constrained to anywhere. That's\n
for this whole XML file. Don't worry about\n
like relative layout and linear layouts as\n
are using constraint layout, which is the\n
application, you need to concentrate or chain\n
if I don't constrain this button to anywhere,\n
Because of the different screen sizes, we\n
of this button. And right now if we run our\n
moved to the place zero and zero, which is\n
to overcome this warning, we can simply add\n
As simple as that I'm constraining this button\n
top and the bottom, I can constraint that\n
that to this TextView. For the button, I'm\n
screen. As you can see whenever I add a constraint,\n
in here as well. Now we don't have that red\n
when we have created this button, when we\n
ID has been added to it as well. The idea\n
that if you want. For example, I can say btn\n
in an XML file, the ID should be a specific\nto every element.
Right now this button doesn't do anything.\n
a little bit more interactive. For example,\n
by clicking on this button. For that we need\n
that we could have access to its attributes.\n
going to switch to full screen so that you\n
in here. If you go to this view option in\n
that we have few options. I'm going to go\n
i'm going to stay with full screen. Okay,\n
file. As I said in the previous video, you\n
here. And that's because when we created our\n
project for that now we have an empty activity\n
also main activity dot java file. In future\n
folds if we select no activity at the time\n
these codes returned to this level. Also,\n
import. If you click on that, you can see\n
class. If you want, you can always minimize\n
you can minimize and maximize all of your\n
imports like this so that we can see what\n
be worried about all of the new keywords that\n
class extends protected void. We will talk\n
But for now, just know that this onCreate\n
application, it means that when we run our\n
braces is going to be the code that will run\n
method that we used. We will talk about that\n
method, two things are happening, we have\n
talk about that right now. And after that\n
content views we are accessing to the activity\n
main in here. Basically it means that this\n
main layout file. We will talk in more depth\n
now just know that up until this point in\n
is related to this layout file. After that,\n
example, in here, I'm going to access to that\n
video for that I can say text view. As you\n
the idea behind the Android Studio is suggesting\n
here, but the one that I need is going to\n
Java, we have classes equivalent to the UI\n
layout file. If we are going to define a button\n
here we are going to use text view. So we\n
you can see, a new line of code has been added\n
the TextView from the widget package into\n
The name is optional, and you can name it\n
going to say txt Hello, this is just the basic\n
you want, but we will talk about conventions\n
TextView you need to locate the TextView from\n
that is like this, you can say is equal to\n
that is useful for finding different views\n
view by ID. Once again, this method is useful\n
elements from your layout files by date ID\n
need to pass the ID of our TextView from inside\n
like this, we can type r r is a special class\n
all of our resources, our static files in\n
let's select that, you can say r.id dot after\n
have which was txt message, I believe this\n
have put inside your layout file for this\n
And we are using that to have access to our\n
view by ID method, and after that passing\n
our text view. But you can see that there\n
in Java, every time you write a sentence,\n
That's just syntactical and it really doesn't\n
semicolon, but in Java, you need to put a\n
now up to this point, we have our TextView\n
if we want to change the text of our TextView\n
the name of our TextView which is txt Hello.\n
this dot operator. We will talk about it in\n
for now just know that when you are typing.on\n
and attributes. For example in here I can\n
have multiple options. Let's import the first\n
You need to pass a text. And whenever you're\n
you're going to hard code the text, you need\n
pass a double quotation inside this double\n
Now we have changed the text of our TextView.\n
going to work. Remember that inside our activity\n
Inside our Java file, we are changing it to\n
see, in here, the text of our TextView has\n
is not interactive, we want to change the\n
we run the application. For that we need to\n
onClick listener for this button so that when\n
changes, there are multiple ways of defining\n
one is to do that inside your main activity\n
your button element inside the anchor brackets\n
can see that we have an option in here. Let's\n
to say on btn clique, this name in here is\n
file. As you can see, right now we are getting\n
method in your Java file. Let's copy the name\n
and create that method. So in order to create\n
scope of this onCreate method. And inside\n
about this, we need to define our method inside\n
this, we can say public void after that the\n
a pair of parentheses, because it's going\n
we need to accept a viewing here, don't worry\n
all of these in Java session. Let's name this\n
braces for our method. And in here, we need\n
the user clicks on our button. If you switch\n
you can see that the red error has been disappeared.\n
I'm going to change the text of our TextView\n
So for that method, I'm going to move these\n
can probably guess the behavior of our application\n
how is it going to work. You can see that\n
click on our button, the text will change\n
what we want. It's just saying hello right\n
For example, we are going to get the name\n
going to say for example Hello may sound Hello\n
get the user's input, the way to get the user's\n
edit text. Let's switch to design view. You\n
going to this text option in here, you can\n
one is for text view, we have seen the text\n
we have other options, plaintext, password,\n
for when you want to get different kinds of\n
we are going to use plain text. Plain Text\n
get from the user. Let's drag that into our\n
in here, you can see that it's ID is edit\n
EDT. txt name. Because we are inside the constraint\n
text as well. But before that, I'm going to\n
I am going to change its constraint from the\n
editors. For that I am going to direct the\n
of this edit text. Now let's add some other\n
example, for the top, I'm going to constrain\n
for the edges. I'm going to go to the edges\n
our text view. If you want we can add some\n
say 70. That seems to be better. The other\n
text in here. I'm talking about this attribute\n
name if you want you can change that but in\n
instead, I'm going to define some hints. You\n
between hint and text is that when you click\n
It's just a hint for the user to know that\n
edit text. For example, in here, I'm going\n
out. Okay, now we have an edit text inside\n
to have access to this edit text so that we\n
start point of our activity. And our application\n
inside this onCreate method, we can have access\n
We can say Edit Text. Once again, you can\n
edit text as well. Also, if you take a look\n
code has been added to our class as well.\n
before, we can say is equal to find view by\n
of our edit text which I can say r.id dot\n
our edit text. Now, we need to get the text\n
dot get text, you can see that we have this\n
to do another level of conversion. And we\n
this two string method yet, we will talk about\n
converting whatever the text is inside our\n
Java file. Don't worry about that. We will\n
with our code in here, we are going to get\n
to the user. When we click on the button.\n
text inside our on button click method. But\n
say Edit Text name, you can see that everything\n
to that edit text inside this method. And\n
Java. The scope of this edit text is this\n
this onCreate method, we can have access to\n
method. In order to solve that problem, we\n
our on button click method. Let's quickly\n
let's paste them. But right now we are not\n
getting the user's input, but you're not doing\n
of code to the set text method. Let's quickly\n
of the set text method. I'm going to pass\n
get text.to string. This way, we are setting\n
is inside our edit text. Let's quickly run\n
This is how our application and this edit\n
you can see that we can type something for\n
on our button, the text of our text view changes\n
we want to say hello to myself. In order to\n
code. Also notice that I didn't put any double\n
passing this text dynamically to our set text\n
we need to put that inside double quotation\n
if we want to say hello to the user, we can\n
quotation, let's add a plus in here. And inside\n
let's add a space so that we could see everything\n
in programming, adding the two texts together,\n
let's type something in here. Let's say Mesa\n
that the text has been changed to allow Mesa\n
Okay, this is our challenge, we are going\n
are going to get the user's first name, last\n
button, we are going to show them inside these\n
about. So if we have a first name, last name,\n
button, we are going to show them inside these\n
application so that we can practice everything\n
you to pause the video in here and create\n
it, come back to the video and we are going\n
I hope you solve the challenge but if not,\n
that in here together. Also notice that whenever\n
of recent projects in the left panel in here.\n
project we can say start a new Android Studio\n
this empty activity. Let's name our project\n
or Let's name it registration for you need\n
the Save location if you want. And also I'm\n
create our project. Let's start by creating\n
jellified for now. And let's also minimize\n
this HelloWorld text, you can click on it\n
in our registration form, we needed to edit\n
need to add three plain texts in here. Let's\n
on. Don't worry about that right now through\n
add that as well. We also needed three text\n
Let's also change the IDs. For the first one,\n
also delete this text and also add something.\n
thing for the other two edit texts. Sometimes\n
attribute for your elements, you can see some\n
avoid that by pressing the Escape key on your\n
let's change its ID to let's say btn register.\n
delete this text. And let's say register.\n
attribute in here, we can define an onClick\n
we did in the previous video in our TextView.\n
let's say on Register btn. Click later on,\n
First of all, let's change their IDs. For\n
first name. Also, let's change the text to\n
and let's greatly constraint all of these\n
one, I'm going to constraint it to the top\n
my screen. Let's also add a margin top of\n
next one, I'm going to constraint it to the\n
also to the bottom of my first name edit text,\n
same thing for this email. For the button,\n
probably change the top constraint. Also,\n
your elements, you can click on the constraint\n
constraint, let's change the top constraint\n
name, I'm going to constraint it to the both\n
just try once again. And also the top constraint\n
once again, let's say 90, I think 90 is fine.\n
now we are not seeing our last name TextView.\n
name, I'm going to do the same thing. Let's\n
say 24. Same thing for the email. Okay, this\n
And now that we have defined our layout file,\n
the behavior of our application, I'm going\n
everything, let's just copy this onClick attribute\n
define this method in our Java file. In our\n
package folder inside our main activity dot\n
Once again, I can say public void the name\n
file, inside the parentheses, I need to say\n
Lord v. And now I have created my own button\n
about the syntax of this method. We will talk\n
Java in here. First of all I'm going to define\n
like this. We can say TextView for the first\n
view by ID r.id dot txt. Firstly, I'm going\n
after you have defined your text views, it's\n
that like this, we can say Edit Text. For\n
name is equal to find view by ID r.id dot\n
to do the same thing for edit text, email\n
have access to all of the UI elements that\n
text views. For example, for the txt first\n
say txt first name. That's a text. We have\n
in here. Let's say first name, plus the text\n
Text first name, dot get text.to string. As\n
of our text view to the text of our edit text.\n
email. Edit Text last name, that's a text.\n
text last name dot get text.to string, edit\n
the wrong element in here. This should be\n
Same thing for the email, txt email.
That's it text. Let's say email plus edit\n
all we need from our application. Let's just\n
good job with the layout of our application.\n
top of this register button and also these\n
all of them better. Let's also test its behavior\n
last name, let's say Watson for the email,\n
register button. And as you can see, we are\n
our application is working perfectly. In this\n
about Java for writing Java applications,\n
development environment. Android Studio has\n
few months ago, you could have right and drawn\n
I think it was around July 2019, that you\n
of a new release in Gradle. I have recorded\n
And it's on my YouTube channel. If you want\n
on YouTube and you will probably find a video\n
that I'm talking about. Andrew the sudo does\n
do now. And you can also see my channel name,\n
basically what I was talking about in that\n
you need to use another ID. The most famous\n
are Eclipse and IntelliJ. In this course,\n
a lot like Android Studio. And also it's free.\n
intelligent Id make sure to check that if\n
Studio beside intelligent, you're going to\n
already installed on our system, you can get\n
say intelligent ID. The first link from the\n
Just one thing that was mentioning here is\n
version and also an ultimate version, the\n
for our needs in this course. So make sure\n
it and also installed it come back to this\n
installed on my system and I'm going to open\n
in here by saying create new project. As you\n
Studio, I have the ultimate version of intelligence\n
These might not be available for you if you're\n
version you're using, you should see this\n
need to specify the path to your JDK. If you\n
of this course you should be good in here\n
my version in here is 13. But we are not going\n
Oracle does not support this version of Java\n
of the features of Java eight. Okay, After\n
click next, we are not going to create our\n
this option. After that, click Next. In here,\n
a location for the name of this project. I'm\n
see these settings in here, you have this\n
that your module name is exactly your project\n
location if you need, I'm not going to change\n
let's create our project. As you can see,\n
And the reason for that once again is that\n
Let's just close this tip dialog. And let's\n
full screen mode. Once again, in IntelliJ\n
minimize and maximize that you can also move\n
use any template our folders are empty, we\n
on the source folder by right clicking on\n
a package for our application. In this case,\n
dot let's say hello world. And inside this\n
worry about the term class that are used.\n
oriented session. But for now just know that\n
in order to run our Java applications. By\n
new Java class we can create our class Let's\n
new Java class has been created in our package.\n
minimize our project pane. Let's focus on\n
we have in here is the package that we are\n
And also we have the declaration of a class\n
later on in future videos. In order to have\n
going to need at least one method and that\n
to create that method we can type p SVM. By\n
As you can see, this green triangle has been\n
our application from this point, we will talk\n
later on in the course. But for now, just\n
you need at least one Java class in which\n
is like the onCreate method of our activities.\n
method. For example, in order to print something\n
this we can say s o UT or south and by pressing\n
System dot out dot print line. Or alternatively,\n
the shortcut, you can say system, notice that\n
to use the upper case for us. Let's say system\n
here it means that we are going to add 14\n
something later on we will see that we have\n
input. Let's say System dot out dot print\n
line. For now we are going to use the print\n
on. In order to print something to the console,\n
you can say something like this. For example,\n
simplest Java application that can be written,\n
to run our Java application for the first\n
braces of our main method and select Run hello.me.\n
hello world into our console. Sometimes if\n
applications, you may get some errors in here.\n
by rebuilding your project, you can come to\n
project. After the rebuild is finished, you\n
clicking and selecting run. Hello, that's\n
But if you had any other problem, please ask\n
notice that for the rest of this section,\n
it is possible to have a graphical user interface\n
this is an Android course and later We've\n
we are not going to use any user interface\n
to understand the language. Okay, now let's\n
talk about the difference between print and\n
print line is that when you are using print\n
will move to the next line. That is not the\n
let's say System dot out dot print. Once again,\n
run our application to see the difference.\n
to run your application, you can right click\n
Hello dot main. Or if it's not the first time,\n
left or the green triangle. On the top of\n
for Windows is shift plus fn. If you're using\n
triangle and see the shortcut. Let's run the\n
print and print line, you can see that the\n
moved to the next line. If we switch these\n
let's switch now. Now print line is the first\n
the application once again. This time, you\n
in two separate lines. Okay, now that we know\n
let's talk about variables in Java. But before\n
lines of code, you can comment them by pressing\n
in Java, it means that you are telling the\n
The use of comment is for developers to remind\n
important. For example, in here I can say\n
line of code will be completely ignored. The\n
we can say slash slash to do after that we\n
of comment with to do at the beginning of\n
the color will be changed to blue. And also\n
can see that you have one to do in your file.\n
multiple programmers. By clicking on this\n
tools. There are more to comments, we will\n
for now just know that when you're commenting\n
Okay, now let's talk about variables. Variables\n
data in your job application. For example,\n
are useful for when you want to store some\n
if you want to store a number or a text, if\n
like this. You can say int int stands for\n
store whole numbers for example, negative\n
to define them is like this. First of all,\n
your variable. For example, in here, I can\n
And you can use whatever you want. After that\n
example, I can say five in here, this is the\n
name of my variable. And this five is the\n
you can also have negative numbers. After\n
some operation on them, for example, you can\n
this, you can say System dot out dot print\n
or whatever is the name of your variable.\n
quotation. Basically, whenever you are passing\n
devil quotation but whenever you're passing\n
quotation, let's run the application and see\n
the value of our number is negative five in\n
have decimal values. For example, in here,\n
in which you can use in order to store decimal\n
The other kind of variable that you can use\n
see that as well. We can see a long, you can\n
say five. Let's also print that, let's say\n
our log. If we run the application, you can\n
long and integer is that you can store larger\n
will store more spaces in your device's memory\n
store numbers as large as the number of two\n
can store numbers as long as the number of\n
between long and integer. But what if you\n
numbers for that you have other kinds of variables,\n
we can say double, let's name it my double.\n
let's pass our data. If we run the application,\n
can see that down in here. So double is one\n
to store floating point numbers. The other\n
well. We can say float, let's name it my float.\n
name your variables, whatever you want, we\n
now you can see that we are getting a read\n
point numbers by default are double in Java,\n
number, you need to cast your number to float,\n
After the equal, we can open and close a parentheses\n
by casting, you will explicitly tell the ID\n
not a double number. Okay, let's quickly print\n
run the application, you can see that once\n
difference between float and double is that\n
And also the other difference is in the space\n
in the device's memory. Basically double view\n
that much in this course, I just wanted to\n
now we have seen numbers. But what if we want\n
that we have a special kind of variable which\n
char is equal to, let's say M. Notice that\n
variable, I have used this single quotation\n
different numbers. When you're assigning a\n
like before we can print our character. Let's\n
You can see em printed in here. When you're\n
characters. For example, in here, I can't\n
error. In order to store multiple characters,\n
we will talk about that in a minute. But before\n
more thing. You can also store something like\n
u 00. A, this is a special Unicode value for\n
and see what would be the result, you can\n
printed into our console. When you're using\n
values as well. You can search for different\n
show the copyright symbol, we can say something\n
If you've run the application, we should see\n
other Unicode values on the internet. Okay,\n
to restore multiple characters, we can use\n
S. After that, like before, we can name our\n
it name is equal to Mesa meaning like before,\n
fascinate and let's run the application, we\n
console. But you may have noticed that there\n
string is not blue, like the other kinds of\n
difference between a string and other kinds\n
that we have talked about so far are primitive\n
do we have talked about classes and objects\n
you are using a class, you can have some operations\n
can say dot and you can see a list of different\n
of them later on in the course. But you can\n
in here is that the string is a class, but\n
one more kind of variables that I'm going\n
Let's see that as well. We can say Boolean,\n
you're using a Boolean, that Boolean can have\n
two values that a Boolean can have. Once again,\n
pass my Boolean in here. And let's run our\n
printed. As I said, Our Boolean can have false\n
False has been printed Boolean is very helpful\n
We will talk about conditional statements\n
about different variables in Java, there are\n
out the Oracle documentation, but probably\n
are all that we are going to use in this course.\n
let's quickly talk about arithmetic operators\n
all of these lines of code, because these\n
these lines of code and not deleting them\n
so that if you need, you can check the source\n
quickly define two new integers, I can say\n
int b is equal to let's say two. You can use\n
kind of operation on your variable. We have\n
that we're going to talk about in here is\n
see them. For example, here I can say, answer\n
arithmetic operator that we are going to talk\n
let's quickly print our answer. And let's\n
answer is eight, it has added B to A. The\n
going to talk about in here is minus which\n
B from a, the answer in here should be four,\n
other one is the star, which is used for multiplying\n
should be six times two, which is going to\n
can see 12 in here, the other one is slash,\n
divide six by two, let's run the application,\n
that you need to be extra careful with this\n
number V in this case should never be zero.\n
And let's see what will be the result. Let's\n
getting a read error in here we are getting\n
exceptions later on in the course. But for\n
our application crashes. Certainly we don't\n
be careful about the second number. Or alternatively,\n
that might occur. We will talk about exceptions\n
of arithmetic operator in Java, and that's\n
It's the person so the remainder operator\n
by b. In this case, if we divide six by two,\n
zero. So right now if I run the application,\n
been printed down in here. But if I change\n
remainder of five divided by two is one. Let's\n
printed from time to time this remainder operator\n
that I need to talk about the slash operator\n
that if we divide five by two, we should see\n
we can see that we can see that we are getting\n
saved the answer inside an integer. If you\n
said that integers can only contain whole\n
numbers, you can use something like double.\n
because the answer itself is an integer. If\n
that a divided by b is an integer. If you\n
the equal sign, you can open and close parentheses\n
this way you have cast an integer to a double.\n
that we are seeing 2.5 so if you want to see\n
just talk a bit more about the plus operator.\n
now if I use plus in here, you can guess the\n
the application. We can see seven down in\n
texts. For example, if I have to text in here,\n
say, Emma. Let's also define another text.\n
can use the plus operator to add these two\n
Full Name is the call to first name, plus\n
you can guess what would be the result. In\n
a spacing here in order to see everything\n
in here is called concatenating in Java, adding\n
plus operator have two usages, it can be used\n
we use it with different numbers, it will\n
to talk about more operators in Java. Specifically,\n
operators. Before doing that, let's quickly\n
project by selecting Java and clicking on\n
project. Let's name this project operators.\n
folder, let's create our package. Let's say\n
code dot operators. Inside our package, let's\n
main. Inside our main class, we are going\n
By pressing tab, we have our main method.\n
operators. Let's quickly talk a bit more about\n
the previous video, when we have to find a\n
a value to that we could have say something\n
is equal to a plus two. Or instead of defining\n
plus two, it means that increase the value\n
be its result. Let's run our application because\n
dot Hello, you can see that the value of a\n
we can say something like this, I'm going\n
plus equal to let's also add some spaces,\n
you can use plus equal in order to simplify\n
again, you can see that the result is the\n
for example, if you want to say a is equal\n
we can say a plus equal one. Or alternatively,\n
well, this a plus plus is going to increase\n
we should see six as the value of a you can\n
use minus as well, we can say a minus minus\n
you're on our application, we can see four\n
a minus equal to let's say two. For example.\n
should see three as the value of a like minus\n
also divided by equal it means that divide\n
answer inside a this sentence in here is the\n
I'm going to write we can say a is equal to\n
the same. If you want to make sure of that\n
application. five divided by two is 2.5. Because\n
answer should be two. So we should see two\n
down in here. Before talking about logical\n
talk about these simplifications. Okay, now\n
comparison operators in Java comparison operators\n
things. For example, two numbers. Before that,\n
to say int a is equal to five After that,\n
After that we can say Boolean answer is equal\n
going to talk about in here is greater than\n
this, we can say, a greater than B, I have\n
a Boolean, this left anchor bracket in here\n
if a is greater than B, assigned the value\n
our answer we should see through, let's quickly\n
application, you can see that answer is true,\n
three, the other kind of comparison operator\n
bracket, right now, a is not less than b,\n
application, we should see false in the console.\n
operator that I'm going to talk about in here\n
equality between two integers. And that operator\n
not equal to b. So if we run our application,\n
run our application. And here we can see false.\n
signs, it means that we are checking for the\n
a single equal sign like in here and above,\n
Let's change the value of b to five. To see\n
let's run the application. Now you can see\n
of comparison operators as well. One of them\n
anchor bracket. And also this equal sign,\n
or if a is equal to b, right now, a is equal\n
run our application we should see through,\n
if A is five, and B would be something like\n
see through once again, we can see through.\n
to something like two, because none of these\n
false, let's run our application. And we can\n
less than equal. And we use that like this,\n
sign this in here means that check if a is\n
now, a is less than b. So the answer should\n
see through. But if we change the value of\n
And we can see false. Beside these, we also\n
And that's this explanation Mark plus the\n
A is not equal to b, this exclamation mark\n
operator right now, a is not equal to b. So\n
we should see through and through has been\n
operators that I was going to talk about,\n
going to use them a lot in our course. Next\n
in Java. But before that, let's quickly comment\n
define a new Boolean, let's say Boolean answer\n
will talk about it, we can say a is equal\n
like two. This is our first logical operator\n
pipelines by using shift plus backslash backslash\n
So in here, this OR operator means that if\n
assign through to this answer, if none of\n
to this answer, right now, a is equal to five\n
the answer should be true. So if we print\n
the application. And you can see through down\n
to six, because none of these conditions are\n
And then here we can see false. The other\n
talk about is to add science. Let's quickly\n
it means that assign through to answer if\n
equal to five and also if B is equal to two\n
assign false the answer right now, none of\n
false as our answer. Let's run the application.\n
change the value of a to five, and run our\n
because the second condition is not true.\n
our application, this time we should see through\n
were the two kinds of logical operators that\n
we have talked about operators that we wanted,\n
going to comment these two lines of code.\n
I'm going to talk about is called if statements,\n
if a pair of parentheses inside the parentheses\n
we can say if a is greater than three, after\n
inside the curly braces, we can put our code\n
So in here, we are saying that if our condition\n
braces. If it's not true, jump to after the\n
say continue. Right now a is five, and it's\n
text printed, let's run our application, you\n
if we change the value of a to something like\ntwo
and run our application, you can see that\n
we can also have multiple conditions. For\n
another pair of curly braces inside these\n
I can say a is less than three. Right now\n
see only this text printed, let's run our\n
three. As for the condition, you can provide\n
if statement parentheses or you can define\n
example, in here, if I say Boolean answer\n
pass my answer. inside these parentheses,\n
minimize this ramping for now. This is going\n
highlighting here, the intelligent ID is warning\n
equals equals to true can be simplified to\n
this is going to work exactly the same. If\n
same result a is less than three. Let's run\n
than three. If we want to negate this answer,\n
variable. For example, in here we can say\n
our application, we should see the first line,\n
is not true because A is true. But in here\n
we have added a negative meaning. Let's delete\n
once again. Besides else, you can also have\n
this if statement. And let's write another\n
this if statement. Let's check that if a is\n
than zero, inside the curly braces, let's\n
I can use something like this, I can say else\n
here we can say if a is less than zero. Once\n
the curly braces, we can say a is negative.\n
For example, I can add another one in here.\n
if statement would mean anything. But you\n
if statement you can have at most one else\n
I can have only one l space this else is going\n
use this else, it means that a is not greater\n
So it is zero. In here we can safely say a\n
for our if statement right now A is true.\n
our application. And as you can see a is positive.\n
application, you can guess it, we should see\n
here. If we change the value of oil to zero,\n
we can see that down in here. So if statements\n
have another one as well, let's comment all\n
Let's see that as well, we can say switch\n
we need to provide the variable that we want\n
here, after the parentheses, I can provide\n
I can define different cases. For example,\n
that we need a column. And in case a is one,\n
see a is one. Also, it's very important to\n
that. I will talk about this break in a minute.\n
you are going to need a break, we can define\n
I can say in case a is to screen something,\n
we can define another case. For example, for\n
statement, we are going to need a default\n
we can say default. And we can print something\n
case, we need the break as well. Let's quickly\n
Let's change that to two. And you can guess\n
And you can see a is two, if we change the\n
application. You can see a is not one, two\n
in here. But before that, let's quickly change\n
will cause our switch statement to break.\n
here at the first days, which is a is equal\n
you can see that even though a is one we can\n
a is two in here. Because we don't have any\n
And we have jumped to the second statement.\n
case in your switch statement. We are going\n
let me just say that I have created my project,\n
folder. Inside this package we have only one\n
I hope that you can come to this point by\n
videos on how to create a project and create\n
loops are useful for when you want to do a\n
print something 10 times like this in here.\n
can just copy and paste it 10 times what in\n
paste yourself whenever in programming you're\n
something wrong. Instead of copy and pasting\n
first kind of loops that I'm going to talk\n
will talk about its syntax. This is the general\n
for. After that we have a pair of parentheses\n
in the first statement we are defining a new\n
whatever you want, and also we are initializing\n
statement is the condition of our for loop\n
condition is not met. And the third statement\n
of i every time that we look PVC inaction\n
we have a pair of curly braces in which we\n
if we want to print something like hello here,\n
braces. So what this for loop is going to\n
new integer called AI and we are assigning\n
we are checking our condition we are checking\n
that we are going to look i is Hello So this\n
we are going to execute the code inside the\n
print hello. After printing Hello, we are\n
case, we are going to increase the value of\n
to loop first of all we are going to check\n
still less than 10 or not. For the second\n
we are going to execute our code. This circling\n
our condition is false. When it's false, we\n
this case, we are going to print hello 10\n
see if we can see Hello 10 times, you can\n
seems to be perfect. Instead of 10. You can\n
example, you can say five, if you execute\n
be printed five times, instead of this five\n
if you had a variable before this for loop,\n
later on, we can pass a instead of five to\n
five, we can say if you run the application,\n
for loop we can also have access to the eye\n
we can print by, let's quickly paint that\n
can see that we are printing the numbers zero\n
in Java. The other point is my loop. Let's\n
going to write the syntax of while loop and\n
This is the general syntax of a wild loop.\n
have a pair of parentheses inside the parentheses\n
than 10. After that we have a pair of curly\n
our code. In this case we are going to print\n
value of a so this condition is always true.\n
are going to stuck in an infinite loop. Let\n
an infinite loop looks like. But before that,\n
that no matter what happens, we are inside\n
In some cases, this might be our desired behavior.\n
that we can exit our application by pressing\n
exit code which is negative one in a normal\n
how can we exit a wild? There are multiple\n
the value of a inside the void loop. For example,\n
in order to increase the value of a so that\n
going to loop through this while loop. So\n
so our condition is true. So we are going\n
going to loop through the cycle until a is\n
no longer met. And we are going to break out\n
one more time. This time you can see that\n
also this exit code is zero which means that\n
without any error. The other way that break\n
quickly add that this time after the first\n
loop it means that we are going to print hello\n
in here you can see that we have printed Hello\n
keyword called continue. Let's quickly see\n
and before this print statement, I'm going\n
equal to eight. Then let's continue. This\n
record of your while loop go to the next round\n
the rest of the code inside the viable break\n
so for example in this case, if A is five,\n
But if a is eight you're not going to print\n
in case if a is nice. If you don't want to\n
change the value of a software inside the\n
I can say a plus was right now if I run my\n
times, because if a is eight, we are going\n
going to jump to the next record and we are\n
and see if we can see Hello four times. And\n
So continue is a useful keyword for when you\n
that we have talked about why loop let's also\n
the value of A in here is five. If we change\n
we know that this condition is no longer true.\n
it means that we are not going to run the\n
we shouldn't see any Hello printed into our\n
any Hello. But in some cases, you may want\n
no matter what the condition is. For those\n
me comment this while loop and let's create\n
you need to type do inside the curly braces,\n
can say System dot out dot print line. And\n
we need to say why. And inside the parentheses\n
we need to say a less than five, after the\n
in this case, because A is equal to five,\n
with that condition, we should see this Hello\n
loops. Let's run the application. And let's\n
can see Hello only once. So do while loops\n
code, at least one no matter what the condition\n
Java called for each loops. But I'm not going\n
that if we know about different arrays and\n
about object oriented programming, we will\n
talk about for each loops after we have learned\n
enough for loops. Now we are going to have\n
challenge, we need to know about two more\n
input. And also we need to know how to generate\n
how these two are going to be useful. In order\n
called a scanner. The syntax in here might\n
talked about object oriented programming.\n
Because we want to have an interactive challenge.\n
and paste the code that I'm writing in here.\n
something like this, you can see the scanner\n
Java dot util package. After that, you need\n
a scanner, after that you can say is equal\n
inside the parentheses you need to say system.in\n
for outputting something system that is useful\n
Now you have a scanner, you can get a number\n
is equal to a scanner, dot next int this one\n
our scanner is going to wait for the user's\n
will see that in action in a minute. But before\n
example, let's say answer was plus the value\n
our scanner. Let's say please enter a number.\n
these few lines of code are going to do. You\n
number text. And in here console is waiting\n
I can say five by pressing Enter. You can\n
our application successfully. So by using\n
integers beside number, you can also get a\n
see that as well. First of all, let's go Something,\n
say something like this, I can say the string\nname
is equal to scanner dot next, you can see\n
string. Don't worry about all of these new\n
programming. We will talk about all of these\n
to need the user's input, we are going to\n
scanner dot, Next, you're going to get the\n
something. Let's say hello, close the name\n
again. In here, first of all, we need to enter\n
is waiting for my name, let's say Mesa. And\n
we can get the user's input. Let's also see\n
to comment these lines of code for now, in\n
say something like this, you can say random\n
to new random. And we don't need to provide\n
in order to generate a random number, we can\n
random dot next int, this method in here is\n
that number. That's the number plus the number.\n
can see that we have this random number. It's\n
number. Right now, our random number is this\n
it's good to define a domain. In order to\n
to this next int method. For example, if I\n
once again, the number should be somewhere\n
number to be somewhere between one to 20,\n
plus, but let's run the application. Once\n
here is completely random. It means that every\n
see a different number, you can see that we\n
that we know how to get a random number and\n
for our challenge. Here is our challenge we\n
this game is to generate a random number and\n
asking the user until you receive the correct\n
After five times of guessing gronke show a\n
our game is going to work. First of all, we\n
that we are going to ask for the user's name.\n
After that, we are going to ask for the user's\n
a positive answer, we are going to generate\n
the users guests. If the guest is correct,\n
and quit the game. If the guest is wrong,\n
the correct number. Also, as a hint to the\n
you're asking for a number tell the user to\n
random number is 10. If the user has guessed\n
higher if the user failed after five times,\n
This challenging here is the combination of\n
make sure to practice before watching the\n
Okay, go solve the challenge. And after that,\n
my solution for this challenge. See you in\n
but if not, that's totally okay. After all,\n
the first application that you're writing.\n
together. Let's start by creating a new project.\n
Once again next, let's name this project gets\n
our source folder, let's create our package\n
that gives me a new Java class. Let's name\n
p SVM and now we have our main method. Okay,\n
message to the user. So let's say System dot\n
After that, we are going to ask for the user's\n
or marry have your name. After that, we need\n
a scanner for that. Let's create our scanner.\n
system.me. After that, let's say string name\n
say hello to the user. Let's say hello, plus\n
permission to start the game. Let's say Shall\n
two option. And here are my two options. Let's\n
But in order to format my text a little bit\n
in here in which you haven't seen so far.\n
this. Yes. So this will be formatted with\n
is special Just for formatting my text a little\n
the user's answer. Let's say eight, begin\n
And after that, I'm going to create a while\n
to one, we are going to continue asking our\n
code and paste them inside our while loop.\n
to store the new users answer for that we\n
dot next int. This way, if you are not going\n
users answer is valid, when it's fun, we have\n
void loop, it's time to generate a random\n
to a new random. After death, let's say int\n
domain, I'm going to say 20. Because I want\n
to add a plus one in here. After that, it's\n
please get a number. And in here, we need\n
Let's say int, user input is equal to a scanner\n
three new variables and their usage as will\n
them. First of all, I'm going to save the\n
say eight times tried is equal to zero initially,\n
say Boolean. As well, initially, it's false.\n
should finish the game. So let's say should\n
Initially, After defining these three new\n
of let's say, why should finish is not equal\nto two.
inside the while loop, first of all, I'm going\n
So let's say times three plus plus, after\n
Let's say if times three is less than five,\n
it's more than five, in the else case, we\n
that, I'm just going to say short finish is\n
line of our while loop. So if we look once\n
met, we are going to break out of the while\n
than five, we are going to check that if the\n
number for that I can say if user input is\n
of husband to true because user has won the\n
while loop let's say short finish is equal\n
if statement. Let's say else. if let's say\n
is our randomly generated number, we are going\n
can say, guessed lower. And of course, we\n
that we can say user input is equal to a scanner\n
here in case the number is less than x. If\n
user to guess higher. And also if you're going\n
user input is equal to scanner dot next int.\n
what we are doing in here. But after the void\n
say if the user has won the game. If that's\n
let's say congratulation. And also let's say\n
the game. Let's say you have guessed in your\n
case, first level, we are going to show a\n
after that, we are going to say what was the\nnumber
let's say the number was plus x. This is our\n
doing in here. First of all, we are showing\n
we are asking for the user's name, we are\n
for the user to enter his or her name. After\n
user's permission to start the game, we are\n
while loop we are making sure that we have\n
we are going to ask again and again until\n
sure that we have the permission, we are creating\n
one to 20. And after that, we are asking the\n
user's input in here, we have defined three\n
one and short finish. Next, we are creating\n
in here. The condition of this viral loop\n
the loop. First thing inside this while loop\n
the first time because the time stride is\n
After that we are checking that if times three\n
input with the randomly generated number.\n
changing the value of this husband to true\n
So we are changing the value of this short\n
is greater than our random number, we are\n
are waiting for the user's input. But in case\n
we are telling the user to guess higher once\n
in case the time strike is greater than five,\n
the case, the husband is still false. So we\n
to true it means that user has won the game.\n
Also we are showing that English try the user\n
if the user didn't want the game, we are showing\n
the random number. Let's run the game and\n
seeing the welcome message. After that it's\n
seeing Hello Mesa after that we are seeing\n
or it was better to say Shall we begin? Let's\n
message. This is our first wide look. Also\n
t that I have used when I have created this\n
t in here. Also beside one and two. If you\n
message once again. So let's say three for\n
message. Okay, let's say Yes to continue.\n
Let's say 10 it says gets lower, let's say\n
my second Troy. Okay, let's run the game once\n
Yes. Let's begin. That's guess another number.\n
higher in order to debug all the features\n
see that after five Troy, I can see the gameover\n
nine. Okay, it seems like our application\n
this video, let's change this message in here\n
Okay, this was our challenge. I hope you solved\n
okay. Later on in the course, we are going\n
that we make sure that we have learned everything\n
a good point to stop the video in here. Just\n
the next video, we are going to talk about\narrays in Java.
See you in the next video. In this video,\n
Up until now if we wanted to store some simple\n
we could have used variables. For example,\n
But what if we want to store a list of different\n
a list of students. for storing a list of\n
The first one that we are going to talk about\n
we can have an array of for example strings.\n
we need a pair of square brackets. After that,\n
I can say students, next I can say new string\n
This new keyboard in here is simple English,\n
of strings inside this square bracket, we\n
if we want to serve five different student\n
that now we have an array of size five. After\n
into it. For example, I can say the students\n
to let's put my name in here It may sound\n
element in which has the index of one in our\n
here and that indexes in Java starts from\n
with an index of one, it means that we are\n
If you want to assign some value to your first\n
with an index of zero. Let's see that as well,\n
can keep doing this for all of our elements\n
to your array elements, you can also get the\n
in here, we can say print the value of a student\n
guess it in this case, it should be Tom. Let's\n
Tom. As you can see, Tom has been printed.\n
to your array elements. The other way is like\n
time of creating your area. For example, in\n
it employees is equal to instead of saying\n
brace. And inside that curly brace, I can\n
or every other value that I want. So these\n
array elements, like a string array, you can\n
example, if I want to put some numbers inside\n
brackets, let's say numbers is equal to, let's\n
curly braces, I can pass my values, let's\n
with different arrays, for loops can be very\n
your array. For example, if I want to print\n
I can say something like this, I can create\n
zero, i less than in this case, the size of\n
After that, let's say i plus plus. Inside\n
numbers with an index of I. This way, I am\n
numbers array before running the application.\n
that we Have a clean console. As you can see\n
into our console. So for loops are very helpful\n
arrays. In here, we have hard coded these\n
our array? For example, if we get some values\n
case, it might be possible that we don't know\n
loops with arrays, if you don't know the size\n
property of different areas. For example,\n
This way, we don't need to be worried about\n
like this. Let's run the application once\n
from one to six. Later on, we will see that\n
can also have different kinds of arrays for\n
classes in Java, but more on that later on.\n
of different items. But there are some limitations\n
after the definition is immutable. Let me\n
When we define our students array, we have\n
to change the size of our array, for example,\n
For example, if you say the students with\n
hover over these five, you can see that array\n
elements in here cannot fit in our array.\n
you should see a problem, let's say print\n
that, let's comment this line of code. Let's\n
getting an exception in here. Once again,\n
application crashes. And the exception type\n
which means that the sixth element does not\n
after you define them, you cannot change their\n
arrays in Java, there are others as well.\n
your arrays. later on. When we use other kinds\n
have all kinds of operations on our array\n
other kinds of collections in here because\n
after we know about object oriented programming.\n
other kinds of collections like array lists\n
I'm going to write a simple application in\n
learned about arrays. Before that, let me\n
start creating our application down in here.\n
the contacts application on the phone, I'm\n
names on a phone for to the user. And after\n
to give the user that contacts number. In\n
going to need a string array, let's say a\n
our names directly. Let's say Mesa. After\n
for that I'm going to create that integer\n
initialize our array. After that, I'm going\n
on the phone. So let's create a for loop.\n
that length, and i plus plus. let's print\n
print names with an index of I. After the\n
a name. So let's say print. Let's say please\n
So let's create that is equal to new scanner\n
is equal to a scanner dot next. Then I'm going\n
I'm going to find the index of the contact.\n
less than names, dot length, i plus plus.\n
say if name is equal to names with an index\n
going to print the contacts number for that\n
But right now there is a problem with my code,\n
or not, and that's because of these two equal\n
see if it's going to work. Let's enter our\n
can see, nothing has been printed. Let's talk\n
hover over the warning in here, it says that\n
signs not equal with a pair of parentheses.\n
two equal signs, you are checking for the\n
talking about the reference inside the devices\n
that variable allocates some space inside\n
a space has some address. And that allocated\n
comparing those two references in here together.\n
can be the same, but the reference might not\n
compare two strings by using these two equal\n
there is a better option for comparing two\n
see that as well. In here, I can say name,\n
can pass the other string. For example, I\n
from the previous videos, I said that the\n
are objects in Java. And because they are\n
For example, this equals method. Once again,\n
in the course when we talk about object oriented\n
is a method called equals in our string class,\n
of two strings by the values. So now, if you're\n
number. Let's run the application. In here,\n
see, we are getting the number. Let's also\n
Sarah is the second contact in our array.\n
is this number in which we have printed into\n
is working fine. Okay, I think that's enough\n
video. Finally, we are going to start talking\n
a very important topic, and it's going to\n
sure to Don't miss the next two or three videos.\n
As I said at the end of the previous video,\n
talking about object oriented programming.\n
we could have defined simple data types. For\n
could have say int number is equal to five,\n
texts, and all sorts of variables that we\n
what if we want to have a more complex data?\n
or a phone or every other object that you\n
the concept of object oriented programming.\n
your own objects, the core component of object\n
you can see that we are inside the class,\n
we can create our own class as well. Let me\n
create a new class. For example, inside my\n
I can right click and by selecting new Java\n
to name my class. For example, I can say phone,\n
to use upper cases for the first letter of\n
spaces or some strange characters as the name\n
to simply name my class form. Notice that\n
example interface and you know, later on we\n
create a class the one that has the CI con.\n
This is how a class looks like it lives inside\n
maker.org is section one. Also if you take\n
a new class has been added into our package.\n
Also every class has a name and besides This\n
access modifiers in few minutes. But for now\n
of curly braces in which we can put our code\n
an object. In this case, we are going to represent\n
objects can have different properties. For\n
have some amount of memory RAM, it can have\n
and all sorts of other properties that you\n
can have properties for your classes as well.\n
some properties to our phone class, we can\n
name. Now we define a property called name\n
the property of my class in here, I'm not\n
when we declare a class, we can reuse that\n
that class with different properties. For\n
would be iPhone, if we define another phone,\n
So for that reason, I'm not initializing the\n
properties to our phone object, let's say\n
memory Ram. After that, let's say int camera.\n
we can instantiate it, we know for sure that\n
main method inside our main class. So if I\n
it in here. And here is how you can create\n
of your class, you can see that when I typed\n
from IntelliJ. Sometimes you may get multiple\n
with different names can live in different\n
at the package that your object lives in.\n
class. After that you need to name your instance\n
say is equal to new phone. This way with the\n
new instance of our object. Now that we have\n
access to the properties of our objects our\n
some property for our class, we can say something\n
name is equal to let's name it iPhone 11.
With the help of this dot operator, you can\n
be precise all of the fields of your class.\n
properties or fields, you can also get those\n
can get them. For example, if you want to\n
like this, we can say print, iPhone dot name.\n
iPhone 11 printed into our console. And here\n
access to all of the fields of your class.\n
RAM is equal to eight. Beside properties,\n
For example, in the case of a phone, you can\n
call somebody. If you want to define some\n
let's see them as built. Let's switch back\n
a method I'm going to write the syntax and\n
all, our method has a name in this case its\n
have an access modifier like we did for the\n
this public in a minute. After that every\n
in this case, we are getting a string called\n
we need to pass some input to this method.\n
method, you can just pass a pair of empty\n
one or more inputs. If you want to have multiple\n
inputs with a comma. For example in here I\n
to do that in here. But you can have as many\n
and also an access modifier. Every method\n
but if you want you can change it. For example,\n
your method. You can also have integers or\n
you can return another class with your method.\n
to return any From your method, you can use\n
talk more about the return type of every method\n
return anything from this method. So we are\n
of my method, I can put my code for example,\n
or at least I'm going to print something.\n
Now that I have created this method, I can\n
my object. For example, in here I can see\n
see that by typing dots, I can have access\n
error error in here. And that's because when\n
for it. So when I'm going to use my method,\n
say our beings are bearing the name of a track.\n
happen, you can see that we are playing some\n
behaviors for your classes, there are a few\n
that you can reuse your method. For example,\n
iPhone dot play music, and I can pass a different\n
time. If we run our application, you can see\n
a time. So the first benefit of using methods\n
for organizing our code. For example, imagine\n
you can pass all the codes for that calculation\n
you can pass all of those calculations to\n
method in order to do the calculation, it's\n
code. Also, by using methods, you can encapsulate\n
later videos. But in here inside your class,\n
that method will be accessible only from your\n
If you go back to main class, you can see\n
over there, it says that this method has private\n
encapsulate different behaviors for your own\n
modifier. You can have access modifiers, for\n
the fields of your classes, I can make this\n
we have three kind of access modifiers, we\n
protected if you don't use anything as the\n
public. So there is no difference between\n
When you use public as the access modifier.\n
that this field is going to be accessible\n
in here, let's say private, if I go back to\n
a red warning, it means that we can no longer\n
modifier of our field or method, that field\n
class, beside public and private we also have\n
later on in the course both private and public\n
going to use in the course for the access\n
private admin group inside there. But usually\n
that we are getting a red warning in here.\n
not allowed in here. Do you use private mostly\n
inner classes later on in future videos. But\n
other classes. When you define them as private\n
classes from the parent class. We will talk\n
classes. For now let's just change this one\n
private as the access modifier of your fields\n
want to limit the access of your fields or\n
classes. For example, imagine that you are\n
for other developers. In that case, you may\n
For that reason, you may want to change the\n
to private but now that we have defined the\n
how can we have access to this name from outside\n
quickly talk about it, we can create public\n
say public as the return type of this method,\n
method, I'm going to say set name. As you\n
getting some suggestions from IntelliJ. Basically,\n
set the name of the setter methods like this,\n
convention. But of course, you can name them\n
to follow the convention. So I'm going to\n
input of this method, I'm going to say
the string, let's say name. Inside this method,\n
to whatever the name that I'm going to receive\n
name is equal to name, the keyword, this is\n
in. For example, right now we are inside our\n
this dot name, we are accessing the property\n
here is the input of our method. So we are\n
we receive, we are the input of this method.\n
is public, we can use it inside other classes.\n
we want to set the name of our iPhone, we\n
delete this line of code. We can say iPhone\n
of this method, I need to pass the name of\n
I don't have access to the field directly.\n
value of that field. But what if we want to\n
write another method. And here is how we can\n
return type of this method, I'm not going\n
name. So I'm going to say a string. Once again,\n
get name, we don't need anything as the input.\n
something. And here is how you can return\n
that, whatever you are going to return. In\n
So I'm going to say this dot name. Once again,\n
names means the name inside our phone object.\n
our main class, instead of saying iPhone dot\n
say, iPhone dot get name. If we run our application,\n
form. Let's run the application. You can see\n
these kinds of methods ourselves, we have\n
can use the help of our ID, we can right click\n
Similarly, we can press ALT plus insert, you\n
We have getter, we have surfer, and also we\n
getters and setters, we can select that. After\n
to create getters and setters for for example,\n
see that Id has created some codes for us,\n
identical to the methods that we created above\n
methods are very usual, Id can help us with\n
getters and setters? Well, there are a few\n
Let's quickly talk about that a bit. For example,\n
to change the value of our fields, we can\n
give them the permission to get the value\n
or vice versa, we can create setter methods\n
value of our properties from other classes,\n
The first reason is encapsulation. The other\n
getter methods, you may want to do some other\n
setting a name for your phone, you may want\n
that case, you can have some validation before\n
that's enough talking about getters and setters.\n
of have these two private, and let's create\n
create any. down in here after everything,\n
say getters and setters. And let's select\n
created these codes for us. But because we\n
ram to private, now we have an error inside\n
iPhone dot memory is equal to eight, I can\n
dot cert memory. And I can pass eight. What\n
objects, we have defined our object. After\n
object, there is another way of instantiating\n
So if I switch back to my phone class, above\n
called constructor. Let's use the help of\n
I'm going to go to generate menu. The first\n
to select all of the fields. And I'm going\n
has been generated for us this is called a\n
Our constructor needs to have public as its\n
that the return type of this constructor is\n
constructor does not have any name. And as\n
all of the fields of our class we are receiving\n
our constructor we are assigning different\n
to the fields of our class. Now that we have\n
our main class, we can see that we are getting\n
expected four arguments both found zero, it\n
we need to pass the values directly to the\n
how you can pass them. The first one was the\nname of our phone
let's say iPhone 11. I don't remember the\n
size, let's say five, I believe the next one\n
one was camera, let's say eight as well. Now\n
this, we don't need to directly set fields\n
let's delete this as well. In this line, we\n
run the application and see if we can print\n
11 has been printed. So when you are using\n
of different properties at the time of instantiating\n
constructors as well. For example, if I come\n
and go to the Generate menu. If I select konstruktor,\n
example, in this case, I'm going to select\n
can see that we have another constructor which\n
if you hover over this phone, you can see\n
switch back to our main class, we can create\n
Let's quickly do that. I'm going to do that\n
And this is the beauty of object oriented\n
can reuse that class as many times as you\n
an entirely new font. Let's name this one\n
time I'm going to use the second constructor\n
and four the memory, I'm going to say 16 you\n
of defining a new phone. Now we have two different\n
kinds of constructors for a class is called\n
types as well. We will talk about it later\n
the video in here. In the next video we are\n
programming. There are many more things left\n
next video. In the previous video, we have\n
how can we create them and also what are the\n
going to talk about some important concepts\n
The first of those concepts is inheritance.\n
example because I think that would make everything\n
to create a class called doc. For this doc\n
For example, I'm going to define a name, let's\n
to define a color, let's say private string\n
let's say private int, legs. And also I'm\n
if a dog has a tail or not, so let's say private\n
create a constructor for our class by pressing\n
here. Let's select all of the fields. Let's\n
class as well, once again, by pressing ALT\n
setter, we can create getters and setters.\n
well. I'm going to say public void, let's\n
the eating behavior of a dog. As the input\n
So let's say let's drink food. And inside\n
let's say eating class our food. Okay, nothing\n
have created these four fields. After that\n
our getters and setters. And we have created\n
I'm doing all of this, let's also create another\n
bird class, let's also have a name. Also,\n
fields, one for the number of legs, private\n
that if our bird has a tail or not, so let's\n
let's say has, for this bird class, let's\n
and setters. I'm going to create my eath method\n
Let's get the name of our food. And inside\n
say eating that food. You probably can see\n
between our bird and dog class. Both of those\n
they have all of these getters and setters.\n
programming, this is not efficient, you basically\n
of defining our bird and dot class like this,\n
oriented programming called inheritance. For\n
animal class. And after that, I will extend\n
see how we can do that inside my package,\n
say animal. First of all, let's add some fields,\n
Let's also copy them from here. And after\n
and setters and our eat method. Don't worry,\n
in a minute, let's say public, void eat string\n
of our foot. Now that we have created this\n
is going to be much simpler. For that I'm\n
bird class. Let's delete all of them. This\n
and constructors and methods, I'm going to\n
that our bird is an animal, we are extending\n
we can customize our birth class as well.\n
a red warning. And the warning in here it\n
available in this package. Basically, it says\n
ALT plus insert in here. And let's select\n
generated this constructor you can also see\n
in our birth class, we are receiving some\n
has rather a strange syntax. We haven't seen\n
super keyword means that do whatever you're\n
class. In this case, our parent class is animal.\n
to the constructor of our animal class. It\n
the fields of our animal. Now that I have\n
to instantiate it, for example, inside the\n
bird. Let's name it Phoenix, let's say is\n
constructor is waiting for our arguments.\n
Nina, we need the color, let's say golden.\n
I'm going to pass to, and a Boolean indicating\n
through. Once again, remember that in our\n
But in my main class, if I want, I can use\n
in this case, animal. For example, if I want\n
like this, I can say Phoenix dot get name,\n
methods. Let's run the application. And let's\n
you can see that the name has been printed\n
you can also have access to all of the other\n
if you remember inside the animal class, we\n
we can use it in our bird instance. For example,\n
Pheonix, that it, I don't know what Phoenix\n
run our application. And let's see if we can\n
you can see in here, Nina is eating meat.\n
you can also change the dog class as well.\n
all of these codes once again. Instead, I'm\n
let's say extends animal, you can see the\n
constructor, you can see that the amount of\n
is a lot less right now, the bird and dog\n
for sure that a dog and a bird are not the\n
other behaviors as well. If you want, you\n
For example, inside my birth class, I want\n
let's say ain't veins, we know that dogs do\n
this constructor and I'm going to create it\n
of my ID, let's press ALT plus insert. In\n
as you can see, the constructor has been changed\n
same it means that do whatever you're doing\n
inside our parent class inside the animal\n
wings hasn't been passed to this super statement.\n
inside the constructor of this bird class.\n
Right now the duck does not have any wings\n
if I switch back to my main class, I should\n
that you need to pass a wink that's also fascinating\n
to we can also create getter and setter methods\n
our bird class down in here, let's press up\n
Now that we have created the getters and setters,\n
For example, down in here, I'm going to say\n
And you can see that two has been printed\n
methods. You can also have other methods inside\n
the spirit class, if I want, I can define\n
I'm not going to receive anything as the input\n
dot get name. Also if you remember from the\n
to the current object that you are in. In\n
have any getname method. But because we are\n
start getting, let's say is flying. So besides\n
child classes with different methods. Let's\n
our main class, let's say Phoenix dot fly.\n
the finding new methods inside your child\n
methods of your parent class. For example,\n
we had this eat method, I'm talking about\n
saying eating food inside our bird class.\n
right in here, I'm going to press Ctrl plus\n
of different methods, I'm going to override\n
going to say that I'm going to change the\n
inside the parent class. Once again, we are\n
whatever you're doing with this parameter\n
can delete this super statement completely,\n
later on. After this super keyword. I'm going\n
just say eating finished. So this way, we\n
inside our child class from what it was inside\n
class, we have executed this line of code\n
after that, so that we can see what's going\n
run the application, you can see that we are\n
finished, if you want to completely change\n
class, you can simply delete this super that\n
to say chewing food instead of eating fruit.\n
this eighth method, but their behavior is\n
if we can see the difference, we can see that\n
is called inheritance in object oriented programming.\n
animal class. You can also continue this inheritance\n
you can inherit the dog object. Let's quickly\n
let's say Shephard. Now in here, I can say\n
again, we are getting this red warning. Let's\n
that problem, we can see that even though\n
But inside our Shephard class in the constructor,\n
parent of this Shephard class, which is dog\n
So you can do this inheritance as many times\n
and extend the shefford class. But I don't\n
to say that you have that option. Okay, I\n
The other concept that I'm going to talk about\n
about polymorphism in the previous video,\n
previous video, I said that one kind of polymorphism\n
for example, inside our animal class, if we\n
accept different number of fields. For example,\n
this is one kind of polymorphism. Now we can\n
ways. Basically, polymorphism means having\n
of polymorphism. But before we talk about\n
sure that if you're going to need that the\n
so far is about this eat method. So inside\n
but also we had it inside the child class,\n
have different forms, it means that we are\n
these methods. This is another kind of polymorphism\n
that are doing the same job differently. We\n
that's with the methods themselves. We don't\n
class. But in here, we can also have another\n
how we can create another method called flight.\n
time inside the parentheses, I'm going to\n
to receive a speed as you can see, the compiler\n
methods with the same name. Now, if I switch\n
are not getting an error but before that,\n
Even though we are not getting error warning\n
first flow method Let me close all of the\n
we are using the first method, but if we want\n
pass some arguments in here. For example,\n
same name when we have different number of\n
different kinds of arguments, for example,\n
if we had another method, for example, in\n
the fly name as well. Let's see that briefly,\n
parentheses, I don't know, let's pass a string.\n
compiler is happy with this way of defining\n
difference in the number of parameters, the\n
in here is also called polymorphism. using\n
okay, let's delete these two, I don't think\n
a good point to stop the video in here. In\n
start talking about composition in object\n
video. In the previous video, we have talked\n
video, we are going to talk about composition\n
videos, I said that classes are useful for\n
type. For example, imagine that you are going\n
systems, for example, you have a system for\n
engine, it can also have a fuel system. If\n
you can create different classes, for example,\n
field system. And after that inside your car\n
to have a car, let's see how we can use composition\n
a class called engine. For this engine, I'm\n
going to define a model. So let's say private\n
integer, private int. I'm going to name this\n
it's just a property of different engines.\n
these two would be enough. After that, let's\n
and setters. Let's create a car class. And\n
that, let's say new Java class. Let's name\n
four fields. First of all, let's pass a name
private string name. After that, let's have\n
that, let's define the color of our car private\n
include or compose an engine in here. For\n
capital E. And in here, you can see that in\n
import that into this class. Let's name it\n
composed only one class inside this class.\n
for a stereo system and your system and everything\n
my point. If I use only one class after death\n
you can see that this engine has been passed\n
passed other data types like integers and\n
the same way that we had for previous classes.\n
instantiate it. For example, inside our main\n
object in here, I can say car, let's name\n
see, the constructor in here requires four\n
for the name. I'm going to pass Mercedes AMG\n
the color, let's say silver. What What should\n
our engine in two ways. First of all, we can\n
For example, in here I can say engine, let's\n
I can pass a model and RPM for this engine\n
say three note for the RPM, let's say 8000.\n
pass it to the constructor of our car for\n
that we can create our car but the other way\n
of your car. For example, I can see a new\n
engine objects directly inside the constructor.\n
we have passed it directly, we don't need\n
we don't use Renault engine, but I think it\n
our car objects, we can have access to all\n
if you want to print the name of our car,\n
Mercedes dot name, or that gets named to riversides.\n
engine of this car? Well, for that, we can\n
model. Plus, we can say Mercedes dot
get engine, this method in here. After that,\n
get engine method will return an engine object\n
on that, let's run the application and see\n
can see the name of our car, and after that,\n
Also instead of using the methods of your\n
For example, in here before the printer statement,\n
is equal to let's say Mercedes dot get engine.\n
you are not sure about the return type, you\n
over in your method, you can see the return\n
method which says public engine get engine,\n
an engine object. Now that you have your instance\n
on that, instead of pressing down the control\n
option to get the return type and for that\n
here is how you can do that, you can click\n
down the control key. This way, you can see\n
your method. These kinds of documentation\n
a third party library or some built in methods.\n
method and press Ctrl Q, you can see that\n
For example, in this case, it says that this\n
the line, you can see some information about\n
can have this kind of information on the methods\n
this get engine method. If we switch to our\n
Let's find that method. And here is how you\n
In previous videos, we have seen how to create\n
have create our comment. But these kinds of\n
we can use a single slash. And after that,\n
You can see that we have these sorts of comments\n
for when you have multiple lines. And in here\n
later on will be shown when you press Ctrl\n
in here, let's say returns the engine of our\n
in here, if we switch back to our main class\n
if we press Ctrl plus Q, you can see that\n
these kinds of commenting can be useful as\n
comments. For example, we can provide some\n
videos. So this way of using different classes\n
in object oriented programming. Once again,\n
example, a stereo system class and also a\n
one by one in here as well. But for the sake\n
this way we can compose different objects\n
talking about composition. Let's talk about\n
let's close this car class. And let's comment\n
times that you don't want to instantiate your\n
here I can say car Mercedes is equal to I\n
here like we did before. Instead, I want to\n
that you can pass null values for your objects.\n
in Java means nothing. It means that this\n
an object is now You cannot perform any kind\n
I cannot say Mercedes dot get name, for example,\n
means that our application is going to be\n
here, it says that this method is going to\n
from previous videos, I said that whenever\n
is going to crash. So the error in here is\n
time error. Let's run our application. And\n
in here we are getting a red warning in our\n
In general, we should always avoid exceptions\n
about how can we do that, but for now, let's\n
is now we cannot perform any operation on\n
inside that object. So whenever you're not\n
you are retrieving some data from a web server,\n
you need to check that if your object is null\n
example, you can create an if statement before\n
is not equal to Now, I'm going to put an if\n
now we are going to call this method but in\n
Let's say the car was now let's run the application\n
are not seeing the exception, which is good.\n
With our value being now we are just printing\n
But sometimes you may want to check that what\n
not means nothing in Java? Okay, let's comment\n
keyword in Java called final. So up to this\n
or variable, because I've said something like\n
For example, later on, we could have changed\n
is equal to five plus five for a plus fun.\n
of our variable. But there are some times\n
your variable wouldn't change. In those cases,\n
how you can do that before the type of your\n
equal to five. Now if I try to change the\n
if I say a is equal to a plus one, you can\n
the warning says that cannot assign a value\n
your variables and classes as final, you cannot\n
Let's also check the case when we define our\n
two line of code. And then in here, I'm going\n
it engine is equal to new engine. Let's pass\n
value of this engine, for example, if I say\n
parameters, for example, let's change the\n
the error, the error says that cannot assign\n
point in here. When you declare your objects\n
of that object. But you can change the properties\n
remember, inside our engine class, we had\n
them, we could have changed the value of two\n
the RPM, because I said something like engine\n
that even though we declared our engine as\n
cannot change the whole instance we can change\n
useful from time to time. Okay, I think that's\n
we are going to have a quick challenge to\n
of object oriented programming. See you in\n
that you are a doctor and you want to check\n
of all, you're showing the name and age of\n
can see a list of different organs in which\n
eye. Let's select that. In here, you can see\n
organ, for example, the name, the medical\n
After that, we gave the doctor the option\n
we are going to open that let's select one\n
left eye closed. Once again, we are seeing\n
in this case. This time, if I don't want to\n
beside one for example, if I put two in here,\n
the list of different organs. Let's select\n
see that we are seeing some details about\n
to change the heart rate. In a normal doctor\n
option. But in here, we just want to demonstrate\n
select Vani, here, the scanner is asking for\n
you can see that heart rate change to 75.
Let's select a stomach. Once again, you can\n
behavior in here, which is digest. If we select\n
Once again, this is a hypothetical situation.\n
the patient to digest the food. Let's also\n
time for the skin, you can see that we are\n
seeing some details. After that, once again,\n
for that matter any other number, we will\n
And as you can see application has been exited\n
want you to practice the object oriented programming\n
past three videos. So make sure to use them.\n
the challenge. After that, come back to the\n
as well. Here is my solution for the challenge.\n
inside my source folder. Let's name it or\n
I am going to create my organ class. Inside\n
let's say private string, name and also private\n
it simple. So I think these two would be fine.\n
And after that, let's create all of the getters\n
to use all of these getters and setters. later\n
delete them. Beside these, I'm going to have\n
details. Let's see that as well. Let's say\n
some details about this Oregon. First of all,\n
After that, let's print a medical condition\n
these that get medical condition. That's all\n
create our organs one by one. First of all,\n
say I inside this iclass I'm going to have\n
have a Boolean indicating if the eye is open\n
After that, it's time to extend the Oregon\n
are using inheritance. Now it's the time to\n
of these two fields. And after that, let's\n
again, I'm not sure that we are going to use\n
If we didn't use them, we just simply delete\n
method. I can do that by pressing Ctrl plus\n
can change Use this method. For example, in\n
eye. Let's say color. Plus this dot get color.\n
other methods as well, let's see them, let's\n
I'm going to change the value of this Boolean\n
And let's fast through. After that, let's\n
opened. Let's say this that gets name, you\n
Inside this class, we are using the getname\n
say plus opened. Let's have another method\n
close. Once again, first of all, I'm going\n
Let's say this dot set opened, and let's pass\n
Let's say this dot get name
plus close. That's all we need inside this\n
for the heart. Let's say heart. For this heart\n
rate, let's say private int rate. It's time\n
And after that, we need to create our constructor.\n
and setters. I'm pressing ALT plus insert\n
for you. After that, it's time to override\n
Oh, and by selecting get details method, we\n
the heart rate, let's say heart rate. Plus\n
all we need to do inside this heart class.\n
say stomache. Inside this Islamic class, I'm\n
these empty indicating if the Islamic is empty\n
Oregon class extends Oregon. And after that,\n
our getters and setters. And after that, let's\n
get details method. First of all, I'm going\n
So let's say if this.is empty, I'm going to\n
empty, I'm going to print something I'm going\n
let's just print the stomach is full. Let's\n
called digest. Let's say public void digest.\n
begin. Okay, we are done with our stomach\n
as well. For this Scan Class, I'm going to\n
going to define a string for the color of\n
an integer for the softness of their skin,\n
is going to be some number from zero to 100,\n
that it's time to extend the organic class.\n
Next, we need to create our getters and setters.\n
method. Inside this method, let's also print\n
dot get color. That's all of our organs. Now\n
package. Let's create a patient class. For\n
a string for its name. After that, we are\n
patient. After that we can create our organs.\n
let's say left eye. Let's do the same for\n
that may be a stomach and a skin. Okay, that's\n
And let's create all of the getters and setters.\n
patient class, inside our main class, which\n
Let's create our main class. First of all\n
After that, we can create our patient object.\n
main. Let's say patient, let's name the patient\n
need a naming here, let's say Brad. After\n
that, we need the left eye which I can say\n
name, let's say left eye. After that, we need\n
say short sighted. For the color, let's say\n
we need the same thing for the right I knew\n
let's change the medical condition to normal.\n
heart. For the medical condition, let's say\n
just say 65. I think the next organ was a\n
would be Islamic. The medical condition, I'm\n
condition, I'm going to say p UD public services\n
empty, let's say false. After that, we need\n
their skin. Or First of all, we need the name,\n
let's say burnt. After that, what do we need,\n
color, let's say right? For the softness,\n
patient object. Now we need to create the\n
going to print the name and age of the patient.\n
gets me after that do the same thing for the\n
So we need a scanner. Let's say a scanner\n
system that. Also, now that we know about\n
scanner is working. This is just the class\n
it inside the constructor of this scanner,\n
this way we have created an instance of this\n
Boolean, let's say Boolean. Let's name it\n
it to false. Later on, we will see that how\n
I'm going to create a while loop let's say\n
continue looping. Inside the while loop, I'm\n
For that I can say choose an organ. In here\n
dot out dot print lines line after line. Or\n
see that as well. First of all, let's go to\n
In here I can say backslash n, this backslash\n
one that I'm going to use in here is called\n
to our text. Later on we will see exactly\n
The next one is right I \n
to receive the user's input. So I'm going\n
next int. We have seen this in previous videos.\n
just going to receive the user's input. After\n
to create a switch statement, let's say switch\n
cases. In case the user's choice is one, first\n
about the left eye. So let's say patient that\n
to give the user the option to open or close\n
the eye is opened or closed. So let's say\n
we need to close it, or at least we need to\n
in here. Let's say backslash, D, backslash\n
say close or close the next we need to get\n
going to close the eyes. So let's say if a\n
we need to say patient dot get left eye dot,\n
we are just going to continue to the next\n
this finding here in case the eye is not opened,\n
eyes. So let's say else, we need the same\n
backslash t Vaughn opened it. Next, we need\n
dot next int is equal to one, we are going\n
In the else case, we are just going to continue.\n
to show the list of different organs. Okay,\n
in here. But let's write the second case.\n
can copy and paste all of these logic. But\n
So for example, in here, let's say get right.\n
also write the case for the heart. Let's say\n
of the heart, let's say patient that get heart\n
to give the user to change the heart rate.\n
T one, change the heart rate. Once again,\n
let's say if the scanner dot next int is equal\n
So let's say enter a new heart rate. After\n
let's say int is equal to a scanner dot next.\n
dot, let's say set rate. And let's pass our\n
before, we are going to continue. We also\n
and also after changing the heart rate, it's\n
rate change to plus patients that get heart\n
The fourth one was for the stomach. So let's\n
the details of the stomach patients that get\n
we had the digest option. So in here, let's\n
Let's see digest. Let's see if the scanner\n
If that's the case, let's say patient dot\n
let's just continue. We also need a break\n
case is for the scheme. Let's say case five\n
we just need to print the details, let's say\n
course after that we need to add a break.\n
And if the user enters any other number than\n
For that we are going to change the value\n
that, we need a break. Okay, I think our application\n
In here, we can see the name and age of the\n
list of our organs. Once again, it's good.\n
of the left eye. And also we have this close\n
this one, let's say to once again, we can\n
can close the left eye. Let's put one in here.\n
closed. Okay, let's check the right eye. It's\n
in order to show the list of organs. And let's\n
which is good. Let's see if we can change\n
the console is waiting for the new heart rates,\n
has been changed to 75. Let's check it once\n
say three. And as you can see, the heart rate\n
of organs. And let's select four in order\n
details of the stomach. Let's digest some\n
Let's check the skin which is five, you can\n
skin. But we don't have any option. That seems\n
then these five we should create the application.\n
as you can see application has been finished\n
is working fine. Let's just delete the getter\n
delete if we didn't use them. Let's check\n
the iclass. Everything that is grayed out\n
we never used this set color method. Okay,\n
I think we have used all of them. Okay, that's\n
this set medical condition method. And also\n
the patient class. Let's see what do we have\n
the setters of this patient class. Let's just\n
Let's see, what do you have inside a scheme\n
and this get softness method. Let's delete\n
this set empty method. And in order to make\n
one more time. Okay, it seems like we don't\n
be fine. Okay, that was our challenge about\n
upload the source code at the links that you\n
them and also, I'm more than happy to see\n
video, we will talk about collections in Java.\n
we have seen simple arrays in Java. For example,\n
names, we could have said something like this\n
square bracket. After that, we could have\n
initialized our string array like this inside\n
the size of our array for example five. The\n
time of instantiating our array for example,\n
and inside those curly braces because I've\n
After that, if we wanted to have access to\n
like this, we could have said print, let's\n
the third element, which is Brad in this case,\n
should see Brad. Let's run it. You can see\n
I said that using these kinds of simple arrays\n
the first limitation is that their size is\n
be changed. Right now we have five elements\n
another item inside this array, we cannot\n
like names with an index of five, which indicates\n
to that, you can see that in here we have\n
we get an exception. Let's see the exception.\n
bounds exception. Also, when working with\n
much options. Later on, we will see that when\n
can operate all sorts of operations on our\n
simple areas. If we want to add a sixth element\n
after that, we can copy all of the elements\n
situation that we have in here. If we want\n
another array with the size of six. After\n
that array. And after everything, we can add\n
say a string array. Let's name it new names,\n
of six. After that I can create a for loop\n
than names dot length, and i plus plus. And\n
to add all of the names to this new names\n
i is equal to names with an index of oil.\n
from inside this names array to this new names\n
After the for loop, I can say new names with\n
we can get around this problem. For example,\n
maybe after that, print the six element inside\n
you can see, this solution is not that much\n
see Jerry has been printed in here. But as\n
And beside that if your array has a lot of\n
this process can be really time consuming.\n
if you are downloading this array from the\n
effective. Instead of copy and pasting the\n
Let's delete all of these codes. In Java,\n
first of which I'm going to talk about in\n
that so we type array list with capsule a.\n
or as some might call them diamonds, we need\n
for example, I can say is string. After that\n
I can say names, is equal to new ArrayList.\n
is one way of defining your ArrayList. There\n
so instead of saying ArrayList string, we\n
here is different. It's an interface. We will\n
But for now just know that there are two ways\n
can we use this list to create an ArrayList\n
again, let's name our list. For example, let's\n
is a slight difference in here. But I just\n
ArrayList. Okay, let's delete this line for\n
if we want to add some elements to this ArrayList,\n
we can use this add method in order to add\n
let's add one. You can use this add method\n
another element, I can simply do that. So\n
Now the size of array list is mutable, it\n
list. After adding some elements to your array\n
the get method. Let's quickly say that, for\n
see names that get you can see that this get\n
in Java start from zero so if I pass zero\n
first element. Right now if I run my application,\n
you can see that Mason has been printed. Also\n
size of your array list. For example, if I\n
can say something like this, I can say names\n
what would be the result, you can see that\n
all sorts of options when using array lists,\n
your ArrayList. For example, I can say names\n
the elements inside your ArrayList. After\n
my ArrayList this time the size should be\n
zero. If you want, you can also remove one\n
see that I can say names dot remove this remove\n
need to pass the whole element. So let's say\n
me quickly comment this line because we don't\n
my son, let's print the first element inside\n
let's pass zero as the index. As you can see,\n
that my Sam has been removed successfully.\n
our ArrayList. Let's like names by typing\n
also check that if an option exists in our\n
method, once again, it requires an object,\n
of code. This contains method returns a Boolean.\n
we have removed my sample we should see false,\n
this to Sarah, we should see through. And\n
ArrayList is empty or not. For that you can\n
empty, we have this method once again, it's\n
in our ArrayList. So it shouldn't be empty.\n
But if we remove Sara before this line of\n
do that names dot remove. And let's pass this\n
you can also get the index of some element\n
quickly see that before everything I'm going\n
I want to have a clear console.
down in here. Let's say print names that index\n
I can pass Mesa. Right now Mason is the first\n
can see that it's zero. But if we don't have\n
if we pass Brad in here, we should see negative\n
printed. When you're using ArrayList you can\n
inside your ArrayList. For example, in here,\n
data types when you are creating a new ArrayList.\n
says that type argument cannot be primitive\n
different numbers, you can use the equivalence\n
integer with a capital I. And now I have an\n
an error because I'm trying to add some strings\n
idea of we can use this integer class in order\n
to every primitive data type, you have a class\n
also check others, we can say Boolean similar\n
And you can check the others yourself. But\n
The other option that you have when you're\n
For example, if you want to sort different\n
you have that option. And the way to do that\n
we can see names that sort you can see that\n
later on in the course we will see this comparateur\n
to source different elements in our array\n
this I just wanted to say that you have this\n
move on from this part. Similar to simple\n
To read through all of the elements in your\n
see that as well. You can say for int i is\n
this time, i plus plus. Inside this for loop,\n
index of AI. This way, we can print all of\n
that, let's comment this line. And let's run\n
both of our elements printed. Okay, that's\n
talk about another kind of collection in Java\n
have some key value pair data. Let's define\n
key value pairs. You can define a map like\n
is an interface. We will talk about interfaces\n
video. But for now, let's move on. You can\n
inside these diamonds, we have these K and\n
in here, if we say anchor bracket, for the\n
key the data type of our keys. For example,\n
to provide the data type of our values. For\n
the data type of my values. Right now I'm\n
it seems like the ID hasn't imported maps\n
And if we take a look at above, in here, it\n
class successfully. After defining the data\n
you need to name your map. For example, I\n
But if I do that, you will see that there\n
about, there is a better way of defining your\n
the change, I can say new hashmap. This time,\n
And if you want we can instantiate our map\n
those extra methods. I don't intend to talk\n
technical, it's about the way that we are\n
It's way above the talk that we have in here,\n
your maps as different hash maps. Okay, now\n
of different keys is a string. And the data\n
If you want to put some elements to this map,\n
contacts that put this is the method that\n
to our map, you can see that right now this\n
a value for the key. For example, I can pass\n
let's pass his email, let's say me sam@maker.org.\n
think if I change the name of my contacts\n
much more better. In order to change the name\n
an option, you can select the whole name,\n
you can go to this refactor in here, and you\n
can use the shortcut, which is shift plus\n
to delete this whole name, you can see that\n
name in both places. So let's say email list.\n
much more suitable. Let's add another element\n
let's say Brad. And let's say brad@gmail.com.\n
I want to have access to those elements, I\n
let's print this statement. Let's say email\n
we have this get method which requires an\n
the key. For example, if I pass Mesa, as the\n
this case, I should see the email. Let's run\n
the email of maysa. You can see that the email\n
lists. When you are using maps, you have all\n
to get the size of your map, you can say something\n
Let's run the application and let's see if\n
want to remove an item from your map you can\n
remove required As an object, in this case,\n
And let's print the size of our map once again.\n
that the size is one. You can also check that\n
way to do that is like this. Let's bring that\n
contain keys. Similarly, we have contains\n
if some value exists in your map. Let's try\n
Brad in here, because we have removed breath,\n
false has been printed. But if I change this\n
seems to work fine. We can do the same thing\nfor the values.
Let's say email list dot contains value. Let's\n
Because it does exist in our map we should\n
other options. yourself. If you want. We can\n
that we have this clear option, it will clear\n
is empty method, it will check that if your\n
you have in here is this values, you can see\n
If you want to copy all of the values of your\n
save it inside a collection. But I'm not going\n
going to say that there is an interface in\n
which is the generic type of all of the collections\n
on when we source different items inside our\n
a primitive data type as the data type of\n
maps. For example, in here, I cannot say int\n
that type argument cannot be of primitive\n
say int, once again, you can use the equivalent\n
But you cannot just use primitive data types.\n
maps and array lists, you have other kinds\n
to talk about them in here, because I think\n
enough and you don't need to know about others.\n
this Oracle webpage, you can see that we have\n
But honestly, these are not going to be helpful\n
are just fine. As the data type of key values\n
You can also have different classes. Let's\n
inside the package, I'm going to create a\n
that inside this student class, I'm going\n
string name, and private integer
Let's have a constructor and some getters\n
class, I can pass it as the data type of my\n
list down in here. I can say ArrayList of\n
ArrayList students, let's say is equal to\n
as you want inside this ArrayList. For example,\n
student, let's say may sound with the idea\n
kind of customized datatype is agreeable with\n
I finish off this video I'm going to talk\n
when we talked about loops in Java, I said\n
for each loop, I said that we are going to\n
object oriented programming and also collections\n
talk about that you can create a for each\n
saying int i is equal to zero, I'm going to\n
to iterate over. For example, in this case,\n
a name. For example, I'm going to say s and\n
I need the list or ArrayList that I'm going\n
going to say students, let's review everything\n
passed the data type of the object that we\n
object is as you can name it, whatever Do\n
colon. And after that, you need to pass the\n
inside this for loop, you can use this s in\n
object. For example, if I want to print the\n
gets me right now our ArrayList has only one\n
say students that add a new student. Let's\n
run the application and see what would be\n
and Sarah has been preempted. So this is in\n
of being the index of the item, it's the item\n
be useful and this is how you can create them.\n
the video in here. In the next video we are\n
example, we will talk about this static keyword\n
main method. Besides that, if we had time,\n
talk about interfaces and abstract classes\n
we are going to talk about some small concepts\n
concepts is this static keyword that we have\n
method. I'm going to talk about that in another\n
package. Let's name this class test class.\n
can have this static keyword for our methods.\n
variables as a static as well. For example,\n
After that I can say a string. Let's say name,\n
I'm not sure if you have noticed or not. But\n
the style of this name has changed to italic.\n
But what does it mean to have a static variable\n
your variables and methods as static, those\n
itself and not to the instances of that object,\n
that, let's quickly have other variables in\n
int, age, maybe another one public, let's\n
doesn't mean anything, I just want to have\n
in here. Notice that when I use the intelligent\n
see my static variable in this list. Once\n
do not belong to the instances of the object\n
these two. And let's create getters and setters.\n
setter for this static variable. Okay, now\n
an instance of that class, for example, from\n
let's name it test class is equal to new test\n
for an age and also a skin color, let's say\n
of the class but how do we assign a value\n
class? Well, you can use the setter methods.\n
name, this method and you can pass a name\n
in here this highlighted warning. What does\n
this name variable even without instantiating\n
test class with a capital T dot, let's say\n
method for this name is static as well, I\n
I can say test class dot name is equal to\n
instantiating this object, we can assign a\n
of that let's move these two line of code\n
I can also delete this setname method safely.\n
variable of this test class, I can say something\n
this time with flirty. That let's say getname.\n
would be the result. You can see that message\n
value of this name variable before instantiating\n
that variable will be the same in all instances\n
instance of this test class, for example,\nif I say test class
second test class is equal to new test class,\n
let's say 30. Black. If I print the name variable\n
be the same. Let's say second test class dot\n
Let's run our application, you can see that\n
methods can be as static as well, let's quickly\n
let's say public static void. Let's name it\n
just print something. This static method like\n
and not to the instances of this object. For\n
class with a capital T dot print something,\n
our object. If you're on our application,\n
now we know that static variables and methods\n
instances of that object. But why would we\n
there are a few reasons for that. First of\n
in all instances of your class. For example,\n
simulating different employees of a company\n
about the employee, for example, the age,\n
all of those, you may have a field called\n
of your employee class, the company name should\n
to declare your company name field as a static\n
and methods is very memory friendly, because\n
or method in all of your application. So no\n
application, the company name field in all\n
as a string can so using a static variables\n
is a downside when you're working with this\n
our test class as well. Let's quickly create\n
Let's name it print, notice that this print\n
not a static now, we cannot have access to\n
method for example, in here I cannot say print,\n
It says that non static method print cannot\n
to non static methods, you cannot have access\n
as well. For example, in here if I try to\n
see that we are getting a red warning in here.\n
field cannot be referenced from a static context.\n
inside a static method. Okay, I think that's\n
Let's quickly delete this class. Also, we\n
Okay, now we know everything about this main\n
is public. It's a static method, its return\n
the input of this method, we are receiving\n
main method is a static, we know that there\n
in our entire application. We are not concerned\n
in order to run Java applications, we need\n
specific syntax. Okay, that's enough. Let's\n
talk about in here is inner class. Let's quickly\n
Inside our classes, besides variables and\n
here is how we can define that class. We can\n
name this class test inner class. And here\n
this in our class, we can have other methods\n
string name in here. I can have a constructor\n
that you can see we can create the constructor\n
And we can treat this class as any other class\n
a class and an inner class. For example, if\n
Let's define some, let's say private int,\n
the access modifier of these fields are, we\n
in our class. But we need to do that inside\n
the page. Inside this method, I can say print,\n
working fine. Even though the access modifier\n
to that from inside our inner class. The same\n
Plus, no matter what the access modifier of\n
them from inside your inner class, there are\n
classes for example, when you use inner classes,\n
to follow. The other reason for using inner\n
access modifier at the declaration of your\n
public access modifier when we create our\n
say private you can see an error in here and\n
privates not allowed in here beside private\n
classes. That is another benefit of using\n
when you created your parent class let's quickly\n
modifier static not allowed in here. So within\n
classes in this course, we are not going to\n
first time that we are going to use it is\n
we are going to define our async tasks as\n
on in the course. Okay, I think that's a good\n
to talk about interfaces and abstract classes\n
have that discussion in the next video. So\n
As I said at the end of the previous video,\n
interfaces in Java interfaces are like a contract\n
see what I mean by that you can create an\n
you can right click on your package by selecting\n
interface, you can have an interface Let's\n
take a look at your package, you can see that\n
take a closer look, you can see that the icon\n
the icon of classes in Java. This is the general\n
interfaces, lives inside the package, they\n
our interfaces, whatever we want. And also\n
declaration. Inside interfaces, we can define\n
abstract method. I can say public, let's say\n
the input of this method, let's just receive\n
it, you cannot have a body for your abstract\n
pair of curly braces, you can see that I'm\n
that interface abstract methods cannot have\n
and I can finish my sentence in here. By using\n
of your methods. For example, in this case,\n
does. Instead, we are just defining some sort\n
of our method, we know that the name of this\n
receiving a string called name. And also we\n
void. The signature of this method is a contract\n
we are going to use this signature. Also if\n
can see that it's somehow grayed out. If you\n
modifier public is redundant for interface\n
in here. And the reason for that is because\n
an interface. It means that you cannot have\n
your interface. You can have as many abstract\n
to define another one in here, I can say void.\n
going to receive anything as the input of\n
name the spawn move. And also let's receive\n
method so that I can show you how you can\n
delete that in here. So this car interface\n
we use this interface? Let's quickly see that\n
a Java class called electric car. And inside\n
that interface that I just created. In order\n
say implements at the declaration of my class.\n
of my interface. In this case, it's called\n
that I'm getting a red warning in here. And\n
the two methods that we have created inside\n
two methods, we have multiple options. First\n
By selecting implement methods, we can implement\n
you don't see this red light, well, you can\n
enter, you can see the same dialog or the\n
of your class. And by pressing Ctrl plus i,\n
In this case, we have a start and move methods.\n
the list of all of the methods that you can\n
bit careful because all of these methods are\n
are these two methods. If you take a closer\n
can see that the icon is somehow not completed.\n
implement or override. Let's select them.\n
and move method, it means that we can define\n
here. For example, in the start case, I'm\n
an electrical car, I'm going to say electricity\n
this class. I'm going to save private string\n
ALT plus insert, let's create that constructor.\n
down in here, let's also define some functionality\n
to print something, let's say this that getname\n
Okay, now that we have created this class\n
we instantiate our interface for that we can\n
main class, we can say car interface. Let's\n
I have two options. First of all, I can say\n
But if I do that, you can see that we are\n
might be our desired behavior. But in here,\n
going to say is equal to new electric car.\n
Tesla, you can see that we are assigning a\n
Well, because when we have created our class,\n
is happy with assigning a class to this interface.\n
we can use its methods. For example, I can\n
also let's say car interface dot move, we\n
Let's run the application, you can see that\n
at 60 miles per hour. You can see that even\n
any body. But we are printing some functionality.\n
If you want to make sure that this start method\n
print something else in here for example,\n
name of this class. I'm going to pass this\n
the current object. In this case, it's referring\n
it will print the address of our class. Let's\n
of our electric car class. It means that this\n
car class and not inside the interface. If\n
we have defined array lists in two ways. One\n
as list for example, because I've said list\n
For example, the stuff a string, let's name\n
now you understand this syntax in here, it\n
which implements this list interface. If you\n
you can press down the CTRL key on Windows,\n
clicking on this ArrayList, you can see the\n
scroll a bit above in here inside the declaration\n
are implementing this list. Don't worry about\n
accept any kind of object but as you can see\n
on from here. Now that we have our interface,\n
this interface. Let's quickly create another\n
this phone fossil fuel car. Once again, in\n
car interface, we need to implement two methods.\n
methods. Once again, let's define some functionalities\n
bring something in here. Let's say explosion\n
I define some functionality for this move\n
here like before, I'm going to say private,\n
and also getters and setters. After that insight,\n
is moving at some speed. Now that we have\n
interface inside our main class, like this,\n
can say car interface. Once again, let's name\n
Like before, I can say new fossil fuel car.\n
Once again, you can see that Java compiler\n
interface because we have implemented this\n
and also fossil fuel car class, we can instantiate\n
after that, I can say fosu car interface dot\n
dot move. Let's also pass some speed in here\n
that both of these methods have been called\n
and implement the same interface in both of\n
an interface, that interface is a contract\n
For example, in this case, I'm defining multiple\n
is, the contract says that discourse should\n
by now you can see the usage of interfaces.\n
example, we can use something called callback\n
useful for when you create event listeners\n
for when you want to create some sort of connection\n
about threads in the next video, don't worry\n
when we want to create a communication between\n
that you can implement multiple interfaces\n
let's quickly create another interface in\n
For this, let's just have a method in here.\n
methods cannot be private, let's say void\nprint name.
After I have created this interface inside,\n
the first interface, I can add a comma. And\n
interface. In this case, it's test interface.\n
the error somewhere inside the declaration\n
i can implement my method. So you can have\n
of your class. Okay, I think that's enough\n
course we are going to use interfaces a lot\n
hang in there if something is vague. Okay,\n
extra interfaces. Let's also delete these\n
methods. For that I'm going to create a new\n
class, I'm going to name this fun test abstract\n
you need to add another keyboard between the\n
add abstract in here you can see public abstract\n
abstract keyword, if you take a look at your\n
class has been changed. This means that this\n
like interfaces. You can have abstract methods,\n
say public abstract, let's say void, and let's\n
name string name. Once again, like interfaces.\n
have a body. For example, if I put a pair\n
warning in here like before I can finish my\n
classes is a lot like interfaces. But there\n
let's see the first difference in here inside\n
let's name this one test class. When we wanted\n
said implements. And after that the name of\n
classes, we can say extends, let's say extends\n
the warning again by pressing Ctrl plus if\n
first difference is between this extends and\n
that when you want to use abstract classes,\n
For example, in here, I cannot add a comma\n
word abstract classes does not support multiple\n
between an interface and abstract class. The\n
class, you can also have non abstract methods.\n
say void. Let's name this method print. Let's\n
say a string text. And because this is not\n
this method. We didn't have this option inside\n
methods inside an abstract class. Like every\n
a constructor as well. For example, let's\n
for this class, you can see that all is working\n
can have fields constructors and non abstract\n
classes like before we can switch to our main\n
class. Let's name it test abstract class is\n
artist abstract class. After that, we can\n
abstract class dot, let's say print name.\n
say Mesa, but we didn't have any functionality\n
some functionality in here. Also know that\n
we have created a constructor inside our test\n
in here as well. But for the sake of simplicity,\n
I just wanted to show that these three options\n
bring something inside our test class inside\n
Let's run the application and let's see if\n
You can see my Sam has been printed. So once\n
class, we have this abstract method which\n
this class inside our test class. And we have\n
class, you can see that there are a lot of\n
classes. Sometimes the decision for using\n
for that let me show you an Oracle web page\n
can see the address in here. I think if you\n
say that use abstract classes when your classes\n
is that when you think that the class that\n
use some common methods or fields or also\n
than public such as private and protected\n
declare some fields that are non static and\n
in interfaces, but they say that Use interfaces\n
other, or in cases that you want to use multiple\n
we can implement multiple interfaces. Once\n
it might be useful. Okay, I think that's enough\n
to talk about concurrency and threading in\n
In this video, we are going to talk about\n
things simultaneously and at the same time.\n
your phone and you're reading a book at the\n
music simultaneously, you may be downloading\n
or doing things at the same time in programming.\n
order to create a concurrent programming is\n
in your device's central processing unit or\n
inside something called a process. All of\n
CPU. By default, when you run your Java application\n
a thread called the main thread will be created.\n
UI thread or the user interface thread as\n
task, for example, downloading a file, you\n
thread. The first option in Java that you\n
You can say thread, let's name this thread\n
other Java class. Let's finish our sentence\n
an interface and that interface is the runnable\n
can say new runnable, you can see that this\n
runnable interface, this run method will be\n
place that you put the code that you want\n
example, let's print something in here. And\n
For example, let's say hello from another\n
need to come down after the declaration of\n
run our application. And let's see if we can\n
has been printed into the console. But how\n
thread and this worker thread for that I am\n
example, inside this run method, I'm going\n
is equal to zero, i less than, let's say five,\n
going to print the value of this I and after\n
see how we can asleep the current thread.\n
say plus I plus, let's say in a worker thread.\n
options. The first one and I believe the easiest\n
say thread with a capital T dot sleep. Inside\n
to pass some numbers in milliseconds. For\n
second, I need to pass 1000 milliseconds this\n
wait one second for the next record for example\n
we are going to wait one second. And after\n
as you can see, we are getting a warning in\n
Java dot Lang dot interrupted exception. In\n
about exceptions. We will talk about them\n
need to know that whenever an exception occurs,\n
that, we need to do something for this error\n
error in here is to click on the error and\n
this surround with try catch, you can see\n
dot sleep method has been moved to this try\n
for now let's move on from this part. And\n
thread so that we can see that the code inside\n
be executed at the same time. So basically,\n
it from here and inside the main thread outside\n
here. I'm just going to change this message\n
and let's see If this code is going to work,\n
of oil two times. Once in a worker thread,\n
the code inside the worker thread and the\n
at the same time. In this situation, we say\n
is concurrent. So once again, when you run\n
will be created by default, in which we call\n
After that inside that main thread, you can\n
The simplest way to create a thread is to\n
And after that, we can pass a new runnable\n
we will create this run method that will be\n
way of defining your thread, there are a lot\n
about. For example, you need to be worried\n
is done. Also, there are all sorts of new\n
and interrupting your thread. I do not intend\n
because in Android, we have all sorts of options\n
fact, later on in the course, we have a complete\n
In Android, we have options like async, task\n
we are going to talk about all of them. But\n
talk about this interrupted exception that\n
an exception occurs, your application will\n
by the operating system. There are all sorts\n
the ones that we have seen previously, were\n
and the one that we can see in here is interrupted\n
need to do something about the exception.\n
we can do about the exceptions.
Let's create an application in which we will\n
going to define two new integers. For example,\n
b is equal to zero. Let's bring something\n
we run our application, right, now, we should\n
down in here. The thing that we can do about\n
it happens, and we can do that by using a\n
example, I can say try. Let's move this line\n
try this in case some exception happens catch\n
arithmetic exception. So let's say arithmetic\n
inside the catch block, we can do something\n
something. In this case, let's say B was zero.\n
get an exception. Instead, we are printing\n
not to be useful. And in fact, in most cases,\n
purposes, but it's much better than a crash.\n
in here is arithmetic exception. If we do\n
the generic term exception. If you pass this\n
exceptions. If we run our application, once\n
here is the same result. The other kind of\n
pointer exception that would occur when we\n
For example, if we had a string in here, let's\n
some operation on our name inside the try\n
let's say, Mesa, if we do that, we are going\n
have done this dot equals method on a null\n
of saying B was zero, let's say name was no.\n
work fine because we are passing the generic\n
pointer exception. Let's run the application.\n
of exception that we just saw was this interrupted\n
interrupt the current thread. For example,\n
downloading some file at the same time, you\n
the interrupted exception, you may get a crash.\n
we have audio exception, which stands for\n
exception, we have all sorts of other exceptions\n
we face them. Also on our exception, we have\n
that method is called print stack trace, we\n
a stack trace, we will talk about this stack\n
and fragments in Android. But for now, just\n
to print something into our console that might\n
Let's run the application in here. You can\n
it says that the exception occurred in line\n
the name of your exception, this is not an\n
information about your exception, this in\n
your application. Okay, I think that's enough\n
Java. In the next video, we are going to talk\n
the next video. In this video, we are going\n
we use Singleton pattern when we want to make\n
class in our entire application. In some cases,\n
we can implement that pattern. For example,\n
you are using a database in your application.\n
complete section dedicated to them. But in\n
Java class named database. Let's quickly create\n
And we will see how we can implement that\n
this database class, I'm going to define a\n
let's create a constructor and also getters\nand setters.
Right now, because we have this public constructor,\n
from this database class. But if you want\n
of this class in your entire application,\n
example, I'm going to say private, static\n
to specify the class that we are in for example,\n
let's say private static database, make sure\n
or dot maker dot Singleton pattern. For the\n
it instance. And that's it. Now we can create\n
how we can create that field, we can say public,\n
inside this field, I'm going to say static,\n
to be the class itself. So I'm going to say\n
as you can see the suggestion in here and\n
instead of just simply passing this instance,\n
to say if let's say now, is equal to our instance,\n
new instance, I'm going to say instance, is\n
a name for the constructor of this database.\n
input of this method in here, let's say the\n
naming here. So if our instance is now we\n
creating that we are going to return it, we\n
case, in case if our instance is not not in\n
instance, right now if we use this get instance\n
sure that we have only one instance of our\n
For example, if we go to the main class, and\n
can have only one instance we can say database,\n
with capital D dot get instance, of course,\n
For example, let's say DB music. Notice that\n
method as a static, now we can use this database\n
are not relying on the instance of this database\n
But right now someone can declare the database\n
in here, someone can say database. Let's name\n
is equal to new database because in our database\n
a name in here and if we do that, we have\n
example, let's say DB movies. In order to\n
I'm going to change the access modifier of\n
I'm going to change this public to private,\n
only from inside this class and not from inside\n
now we have an error in here and the error\n
changing the access modifier from public to\n
creating multiple instances of our database\n
our database is private, we can use this constructor\n
see in line 10, in here, right now, because\n
this, if statement that we have put in here,\n
of our database class. But there is also another\n
that's when someone tries to create multiple\n
In some cases, if someone tries to create\n
they might be successful in doing such a thing.\n
safe, we have an option in here after this\n
in which we haven't seen so far, we can say\n
make our get instance method thread safe,\n
call this get instance at the same time. So\n
of all, you declare a static field of the\n
database, after that, you create a get instance\n
also synchronized. Inside that get instance\n
of your database is now or not, if it is not,\n
are calling this get instance method. So you\n
doing in line 10. After that, we are returning\n
not going to create a new instance, we are\n
beside this get instance method. In order\n
you need to change the access modifier of\n
be usable only inside your database class.\n
for example, in here, I can delete this whole\n
from line 11 in here, and after the if statement,\n
we reach to this line 13 in which we are returning\n
is not not and we are returning either a new\n
think that's enough talking about the singleton\n
that this pattern might be useful from time\n
going to talk about one more methods available\n
called to string right now we don't have any\n
But if we switch back to the main class, and\n
see that we have such a method. And if we\n
about our database class. Let's quickly run\n
You can see that we are getting the address\n
change this for example inside your database\n
down in here inside the scope of our class,\n
can select this two string method. Right now\n
want to change that we can delete this whole\n
here. For example, we can say a string text\n
that, let's add a line. And after that, let's\n
Let's say name plus the start name. After\n
we can say return text. Now that we have overrided,\n
we should see some other results printed into\n
method can be useful as well. It's available\n
print some detail about that class. Okay,\n
for that method. I think that's enough talking\n
we have learned a lot in the next video we\n
to make sure that we have learned everything\n
off this video, I'm going to say that with\n
besides writing Android applications, you\n
for Windows, Linux and Mac OS operating systems.\n
you can use Java in order to create enterprise\n
language. For example, you can use Java in\n
You can also use it for data analysis purposes,\n
In this course we have touched the surface\n
more, I'm currently recording a new course\n
find that course helpful beside the Java course\n
framework in order to create web applications.\n
courses may be released, so make sure to check\n
next video, as I said, we are going to have\n
Here is our final challenge for the Java section,\n
and messages applications. Here is how our\n
we are going to greet the user with some message.\n
to the user, one for managing the contacts,\n
another one for creating the application.\n
which is managing the contacts, we are going\n
of the contacts another one for adding a new\n
contact. One more for deleting a contact.\n
menu, which was these three options. But in\n
which is handling messages, we are going to\n
to see a list of all of the messages. The\n
last one in order to go back to the previous\n
three options. In case if the user selects\n
the application. We haven't talked about databases\n
if you want to store contacts and messages,\n
the video in here and go solve the challenge.\n
for this application. Okay, let's go to see\n
First of all, I have created my project, and\n
folder. Inside this package I have created\n
method. Let's continue from here. First of\n
called message. Inside this message class,\n
private string text. Another one, let's say\n
here is going to be the name of our contact.\n
called ID, let's say private int ID. This\n
here. But because in most cases, when you're\n
called ID in order to identify every unique\n
a real world application. I just wanted you\n
is a message. Okay, now that we have these\n
And let's accept all of these three fields.\n
I'm not sure that we are going to need all\n
we didn't use them, we will delete them. Also\n
another method called get details. Basically,\n
message. So let's say public void. Let's name\nit get details.
Let's say print. First of all, let's say contact\n
that, let's print the text itself. Let's say\n
a plus in here. Sorry about that. And I think\n
be much better. After the text. Let's also\n
our ID. That's it for our message class, let's\n
New Java class, let's name this phone contact.\n
four fields, let's say private string, name,\n
this number should be an integer, or maybe\n
have different formats. For example, they\n
I am saving this number as a string. But if\n
After name and number, I'm going to save another\n
After all of these, I'm going to have another\n
of different messages. Let's name this phone\n
different messages for every contact inside\n
fields, let's quickly create our constructor.\n
because at the time of creating a new contact,\n
that, I'm going to create another constructor\n
of different messages. This time, let's select\n
do anything about this messages, this ArrayList\n
to see these dots messages is equal to new\n
contact, I'm saving the messages array list\n
have two constructors in here, let's quickly\n
that, let's create a get details method. Let's\n
use two string methods. But in here, I'm just\n
let's print all of the information about each\n
After that, let's print the number and email.\n
switch to main class. And let's write the\n
here, I'm going to create an ArrayList of\n
that inside this main method because we are\n
to have access to our contacts are released\n
define my ArrayList above in here in the fields\n
because the methods that I'm going to use\n
this ArrayList as a static, so let's say private\n
name it contacts. But this is not a good place\n
this is not the place that our code will be\n
for example, inside this main method. But\n
a scanner in here because we are going to\n
say private static scanner, let's name it\n
let's initialize our contacts ArrayList. Let's\n
you can see in here, I'm going to greet the\n
After that, I'm going to show these three\n
to have a clean code. I'm going to show these\n
name that method show initial options. But\n
warning and that's because I need to create\n
static void, show initial options. Let's bring\n
get the user's input. And for that we can\n
Right now we have declared our scanner above\n
a good place to initialize our scanner in\n
scanner. Let's pass the system that after\n
scanner dot next int. Let's create a switch\n
In case the choice is one, we are going to\n
that in another method, let's say manage contacts.\n
create this method later on. Let's also add\n
is to, we are going to handle the messages.\n
choice is three, or for that matter, any other\n
So in here, I can say default. In the default\n
Let's minimize this project main for now.\n
First of all, let's manage our contacts. Let's\n
Once again, in here, I'm going to show a list\n
One, once again, we need to get the user's\n
say int choice is equal to a scanner dot next\n
scanner in here. And that's because we have\n
method. So by this time, we have an instance\n
need to create a switch on our choice. In\n
the contacts, let's create that method, show\n
also write the rest of the cases. In the default\n
menu. So I'm going to once again run this\n
see all of these options once again. So in\n
options. After that in here, we need a default\n
I'm going to go back to the previous menu\n
Okay, let's create these methods one by one.\n
the contacts. I'm going to do that down in\n
of your method, you can use the help of your\n
in here and by pressing ALT plus insert, the\n
can see that we have created this method successfully,\n
down in here, I can't create the logic for\n
of the contacts, I'm going to simply create\n
name it see inside our contacts, or at least,\n
that we have created inside our contact class.\n
show the initial options. For that I'm going\n
to quit the application when the user tells\n
Let's just minimize it for now. And let's\n
contacts. Once again, we can use the help\n
we are going to receive some users input.\n
Let's say adding a new contact. After that,\n
Once again, we are going to use our scanner,\n
dot next, after we get the contacts name,\n
once again, let's bring something in here.\n
see string number is equal to a scanner dot\n
he made is equal to a scanner dot next. After\n
something as the name number and email of\n
leave us with empty strings. For that, I'm\n
name dot equals an empty string. Let's say\n
Or if email is equal to an empty string. If\n
show some message to the user we are going\n
Let's say please enter all of the information.\n
to recall this whole method I'm going to start\n
I'm going to say add new contact. I'm calling\n
called a recursive call, you can see the icon\n
that you can see the recursive call calling\n
way of calling our method, we are starting\n
but in the else case, we are going to create\n
let's name it contact is equal to new contact.\n
and email. If you remember inside our contact\n
we are using the second constructor, we didn't\n
in here. After creating our contact object,\n
Let's pass our contact. As simple as that.\n
if statement. Once again, I'm going to show\n
options. Because once again, we are not going\n
tells us Ok, we are done with our second method.\n
create this search for contact method. The\n
method first of all we are going to ask for\n
let's say please enter the contact name. Let's\n
next. After that we need to make sure that\n
dot equals an empty string. We are going to\n
the contact name once again. Let's say please\n
are going to use a recursive call. We are\n
But in the else case, we are going to search\n
For that once again I'm going to create a\n
name it see inside our contacts are a list.\n
name that we just received. If that's the\n
also define a Boolean before this for loop.\n
Let's say Boolean. Let's name it does exist.\n
Wherever you have found the contact first\n
does exist to true, let's say it does exist\n
I'm going to create an if statement, I'm going\n
Then we are going to print something I'm going\n
After all of these logics, we are going to\n
say show initial options. Okay, that's it\n
create this delete contact method. Once again,\n
name. So let's say please enter the name.\n
to a scanner dot next, next, we need to create\n
empty string, we are going to ask for the\n
from the beginning of this method. In the\n
ArrayList. So let's say for contact see inside\n
let's also define a Boolean above in here\n
Let's say Boolean does exist. Let's initialize\n
know why I said as in here, let's quickly\n
that gets name is equal to the name that we\n
all, we are going to change the value of this\n
to true. After that, we are going to remove\n
can save contact dot remove. This remove method\n
see the object that we are currently looking\n
going to say if does exist is not equal to\n
such contact. And after all of these logics,\n
initial options. Okay, that's it for this\n
have created the logic for the first option\n
whole logic for this manage contacts. But\n
option, we have one or two possible points\n
two and also we are going to write the rest\n
video. See you in the next video.
In the previous video, we have created the\n
if you remember I said that we have some issues\n
And in this video, first of all, we are going\n
this add new contact method. In here we are\n
list. But before that, we need to make sure\n
saved on our device for that before adding\n
going to check that if I have such a contact\n
a Boolean in here. Let's say Boolean does\n
that, I'm going to create a for each loop.\n
I have a list. Let's see if c dot get name\n
Inside this if statement, I'm going to change\n
say does exist is equal to true. After the\n
exist is equal to true or not. Let's say if\n
to print something we are going to say we\n
we are going to start from the beginning of\n
new contact method once again. But in the\n
my account. Tech's ArrayList, so I'm going\n
going to paste them inside this else case.\n
array list, I'm going to show some message\n
Okay, that's the fix that we needed inside\n
the show all contacts method a little bit\n
printing the details of a contact, I'm going\n
to be just a separator that will indicate\n
Nothing special in here. Okay, let's move\n
created in here, this manage messages method,\n
that method. First of all, we are going to\n
After that, we need to receive the user's\n
a scanner dot next int. And let's create our\n
Vaughn, we are going to show a list of all\n
we will create that method in a minute. But\n
the other cases. In case it's true, we are\n
send a new message. And let's add a break.\n
the initial options. After that, in here,\n
this show all messages method. In here, first\n
from all of the contacts into an array list.\n
Let's name it all messages is equal to new\n
a for each loop. For contact, see inside my\n
that at all, we haven't used this add all\n
I'm going to say C dot get messages. So by\n
of the messages of one contact to our all\n
going to check that if the size of these all\n
messages that size is greater than zero, I'm\n
So for that, I'm going to create another for\n
let's name it m inside out all messages, at\n
after that, let's also print some separator.\n
you do not have any message. After everything\n
the initial options. Okay, that's it for this\n
the other method, which is send a new message.\n
contact or recipients name. So let's ask the\n
send a message. After that we need to get\n
name is equal to scanner dot next. After that,\n
or not for that, I can say if name that equals\n
to enter a name. So let's say please enter\n
going to have a recursive call. So in here,\n
the else case, I'm going to check that if\n
For that I'm going to define a Boolean in\n
After that, I'm going to create a for each\n
contacts or at least if see that gets name,\n
Let's say it does exist is equal to true.\n
if does exist is equal to true or not. First\n
else case, I'm going to say there is no such\n
have such a contact, we are going to ask for\n
you going to say? Let's say a string text\n
we need to make sure that this text is empty\n
string. If that's the case, let's say please\nenter some message.
And after that, we are going to start from\n
send me a message, which once again is a recursive\n
create our message object. And after that,\n
exists in our contacts ArrayList. But if you\n
a field called ID. Basically, whenever you\n
or maybe a web server, this ID is unique to\n
close as I can, and to a real world application.\n
to have a unique ID for every message, I'm\n
my main class I am talking about here. And\n
this ID by one every time that we create a\n
static integer. Let's name this phone ID.\n
that down in here, when we create our message\n
I can say ID plus plus. So because this ID\n
its value, it's going to be unique for every\n
our recipient, which we have received above\n
which is this text. And also we have generated\n
things that we need in order to create our\n
it new message is equal to new message we\n
which is name. And after that, we need the\n
to add this message to his or her array list\n
to create a for loop. Let's say for contact\n
say if see that get name is equal to the name\n
of all, we need to get the array list of different\n
array list of messages. Let's call this ArrayList\n
After that, we need to add this new message\n
new messages that add new message Sorry, I\n
this all. After that we are going to save\n
because later on we are going to remove this\n
we are going to update his or her array list\n
to add it once again to our contacts ArrayList.\n
it current contact is equal to see. Next we\n
And we need to pass our new messages are released.\n
our contacts or at least we can say contacts\n
Now that we have removed the previous contact,\n
dot add. Let's say current contact. So this\n
specific contact and we have updated our contacts\n
we need in order to add a new message just\n
method. We need to show the initial options\n
let's see what else do we have? I think we\n
to test our application. So let's run the\napplication.
In here we are seeing the greeting message,\n
initial list of options. If we select one,\n
contacts. Right now we do not have any contacts\n
can see that we are not seeing anything, it's\n
if we do not have any contact in our phone,\n
contact on your device, but we will write\n
other options. Once again, let's select Manage\n
contact, you can see that the console is waiting\n
is waiting for a number. Let's add some number.\n
let's say may sam@gmail.com. And as you can\n
to make sure of that, once again, you can\n
saying show all contacts. And in here you\n
another contact. Let's say Sarah, this thing.\n
This time let's try searching for a new contact.\n
the console is waiting for the name of our\n
see that we are seeing this message there\n
let's try searching for contact this time.\n
the details about Sarah. Let's also try removing\n
to delete a contact, let's say me Sam. In\n
if that we have deleted Maxim successfully\n
we should see only Sarah. And as you can see,\n
also try this go back as well. So let's say\n
put any number beside one through four, for\n
are going back to the main menu. Also, let's\n
Sorry about that, I need to go back and select\n
Let's don't provide anything for the name.\n
some input. But even if the scanner moves\n
in order to prevent adding an empty contact.\n
again. Let's add some number. And some you\n
option. In order to see a list of all of the\n
message you don't have any message. Once again,\n
two in here and let's try sending a new message.\n
say Sarah, what are you going to say? Let's\n
crash and the crash happened because of this\n
Okay, let's take a deeper look into our code.\n
time. It seems like the exception occurred\n
you can see the line 99 in here, if you click\n
Yes, we have this exception inside the add\n
for loop. I think the error in here is happening\n
to assign a new value to this current contact.\n
remove this contact from our contacts ArrayList.\n
exception. If you want to get over that exception,\n
in here I'm going to delete all these three\n
new messages are released. We have added our\n
in order to update the array list inside this\n
I can pass my new messages ArrayList. So no\n
into our ArrayList. concurrently. Let's run\n
if we are seeing the exception once again.\n
let's say manage contact, add a new contact.\n
some email. And now we can send a new message,\n
are you going to send a message? Let's say\n
line of code, we got the exception. Let's\n
have added or we have sent a new message.\n
go to the messages option. And you can show\n
see that we have one message in which we have\n
Once again, let's go to this messages option.\n
So if I type three or any other number beside\n
main menu. For example, let's say for and\n
options. For the last thing, let's try creating\n
created the application successfully, let's\n
show all contacts method. If you remember\n
in case if we don't have any contacts in our\n
going to check that if we do have any contact.\n
size is greater than zero. First of all, let's\n
just going to print you do not have any contact.\n
same thing that we were doing previously.\n
order to see that these changes are effective\nor not.
So right now, we do not have any contacts\n
why we are losing the contacts that we are\n
we are not using any permanent data storage\n
list and that ArrayList will be cleared when\n
all of the contacts are being removed whenever\n
contacts. And let's say show all contacts,\n
have any contacts. But it's better to show\n
we print this line of code. So down in here\n
initial options. Okay, this was the last video\n
for this challenge. Your solution is probably\n
there are multiple ways of creating the same\n
and learned everything that we have talked\n
of the course, we are going to switch back\n
about user interface and how we can design\n
you in the next section. What's up everyone,\n
our talk about user interface, I just wanted\n
of the scores that you can watch. by enrolling\n
access to more than 60 hours of videos, you\n
I will come back to you within hours, you\n
that I write in the videos. And also you can\n
I upload. Just check out miko.org for more\n
to use Free Code Camp as the coupon code to\n
in Android app development. Taking the extended\n
I just wanted to remind you that there is\n
can take without further ado, let's just start\n
Hello everyone and welcome back. This is the\n
are going to talk about a lot of concepts\n
We are going to talk about a lot of UI elements\n
about different kinds of event listeners,\n
UI elements. We will talk about how can we\n
different screen sizes, and also different\n
about material design and all sorts of stuff\n
ado, let's jump into our project. And let's\n
I'm no longer using IntelliJ ID, and I've\n
ID for the Java section of the course. But\n
just in case if you forget how to create a\n
start from scratch. Let's start a new Android\n
a template. If you remember, I said that these\n
some level. Later on in the course, specifically,\n
see that how can we create all of these from\n
empty activity. After that in here, we needed\n
application, I'm going to say UI basics. I'm\n
it's fine. We needed a save location. Once\n
I'm going to say Java for the minimum API\n
most videos for this course, I'm going to\n
of these, let's just create our project by\n
It seems like our project has been created\n
let's have another look at this class that\n
let's minimize this Ron pane.
As you can see, this is a Java class in our\n
main activity. This class is extending the\n
this class, we have this onCreate method which\n
of this app compat activity. And also above\n
are importing this app compat activity and\n
will talk about them later on in the course.\n
of a simple Java class in here as well. If\n
activity, a Java class and also XML file will\n
the behavior of your application. For example,\n
input in the Java file, you may decide to\n
now that we know about Java, we can understand\n
is a part of something called the activity\n
videos. But for now, just know that this onCreate\n
a simple Java application. This is the start\n
our application has only one activity, this\n
So this line 13 in here would be the start\n
statement in here. Once again, it means that\n
class. In this case, the parent class is this\n
are not concerned about that. But as you can\n
which is a bonded to the super statement.\n
important to note that inside activities,\n
this option in Java. For example, you can\n
see the declaration of this method anywhere\n
using it, you are not getting any red warning.\n
a lot of other inner methods inside an activity,\n
Okay, let's move on from this part. And let's\n
wanted to have another look at Our application\n
know about Java, okay, let's close this java\n
main dot XML file. If you remember in the\n
is a markup language. Once again, if you are\n
languages. Those are just helpful for defining\n
the user. Before everything. Let's scripting\n
we are inside the Android view. And if you\n
you can come to this Resources folder. down\n
see the file. And if you switch to projects\n
inside the app folder. Inside the source folder,\n
have the Resources folder. Once again, inside\n
dot XML file. Okay, let's switch back to Android\n
for now, if you remember from the previous\n
you want to define a layout file, you have\n
design view for example, by dragging some\n
You can have different elements and later\n
elements. This is one way but the other way\n
everything that you need. In my opinion, when\n
times you are going to work with the TextView.\n
TextView. First of all, if you're not seeing\n
it and disable it from this preview option\n
suggestion is to disable this review, because\n
time. And that's going to load a lot of pressures\n
For that if you have low memory RAM, disable\n
Right now inside this simple layout file,\n
I click on this TextView this TextView inside\n
that these are the same. I'm going to delete\n
it. And let's press Delete. The next thing\n
change this constraint layout. In future videos,\n
is. But for now, for a starter, I think it's\n
select that. Also, if you have noticed, you\n
tag in here to relative layout, the closing\n
well. Inside these opening and closing tags,\n
if I want to define a TextView, I can open\n
In capital T, we have a list of options. Let's\n
after pressing Enter, we are getting some\n
need at least two attributes a width and also\n
can be some numbers. But Alternatively, you\n
as well. We will talk about this match parent\n
let's just select wrap content. Basically,\n
view for the height. Let's also select wrap\n
your text view by adding a slashing here.\n
if you want to have more attributes, you have\n
slash I'm going to say let's say text, you\n
recall that text let's select that. And in\n
As soon as I type this, you can see that text\n
the attributes of this text view. Let's talk\n
For example, right now this text is at the\n
going to change the position of this TextView\n
multiple options First of all, I can add some\n
TextView at the edge of the screen. For example,\n
50 dP dp is the unit when you're working with\n
some margin, but we can be more specific for\n
margin right and also margin bottom. For example,\n
time, margins are extremely useful but in\n
this is not accurate, we want our TextView\n
that, instead of using a margin, I have a\n
in order to center my text view horizontally.\n
in here, let's pass through. And this time\n
If you want, you can also center it vertically\n
of true, you can see that it has been centered\n
two, you also have another option. For example,\n
these attributes. Instead, I'm going to say\n
pass through as the value of this attribute.\n
elements inside its parent element. an XML\n
And above them, we have the parent elements.\n
is a relative layout. If we want, we can have\n
other UI elements. And inside that element,\n
kind of inheritance as many times as we want.\n
element. And this relative layout is our parent\n
attribute, it's going to center our TextView\n
from this part. If you want, you can also\n
can say text size, this attribute in here,\n
can say 20 SB. When you're working with the\n
see that it's larger now. Also, if you want\n
For that we can say text style. This attribute\n
normal. For example, let's fast bold. If you\n
you can add a pipeline in here. And after\n
see both of these attributes in the same element.\n
of your text for that we can say text color.\n
be defined inside another XML file called\n
color, accent, color, primary and color primary\n
corners. Let's select the first one. And as\n
But where does this color dot XML file locates\n
a look at that, you can open the project pane.\n
folder, we have this colors dot XML, you can\n
the exact name that we just saw. Don't worry\n
kinds of XML files in future videos. But for\n
So instead of passing a color from inside\n
the hexadecimal value of that color. For that\n
Let's search that. For example. Let's select\n
in here, you can see the hexadecimal value.\n
from inside our color dot XML file, I'm going\n
see that the color of the TextView has been\n
If you remember from the previous videos of\n
to have access to all of these UI elements\n
add an ID attribute for this TextView as well,\n
plus ID slash. Let's select that. And let's\n
ID attribute should be unique inside every\n
inside the same XML file cannot have the same\n
file in order to have access to this TextView\n
but I think if we continue we are going to\n
this TextView. And I'm going to define a button\n
I can open an anchor bracket. And in here\n
select the first option. Once again, we have\n
let's talk about the difference between this\n
I select match parent, let's also select match\n
button is covering all of this screen. And\n
to match parent. If you want, you can change\n
here you can see the difference the width\n
the buttons content. Let's also change the\n
and match parent, you can always pass the\n
DPI, you can see that the width has been changed.\n
application is going to be installed on devices\n
we put some numbers for these, if we pass\n
position of every element. And also sometimes\n
some devices. So for that matter, I'm going\n
Also, now that I have talked about different\n
inside this preview, you have this option\n
that, you can see a drop down. And from here,\n
example, let's select this font, and you can\n
screen sizes. For example, let's take a tablet,\n
worry about this. Later on in the course we\n
look for our application in different screen\n
above in here. Like for the text view, we\n
Let's say text. And let's say Say hello. Similarly,\n
I'm not going to do that right now. Instead,\n
TextView. For that we have an attribute called\n
need to pass the ID of the other element.\n
the ID of this TextView I can say at plus\n
see that the button has been moved to below\n
we want, we also need to center it horizontally.\n
and we can pass through. Let's also add a\nmargin top.
Let's say margin top. And let's pass for example\n
texts here and button you have another attribute\n
can say background. And for example, we can\n
you can see that the background color of this\n
the same option for the TextView. If you want\n
color. So I'm going to change that. Let's\n
dark. Nope, this is not my color. Okay, this\n
value of the color that you want in here as\n
another attribute called on click we have\n
created our first Android application, you\n
listener for this button and we are going\n
button. So let's say on click, and let's pass\n
going to see on Hello btn clicked. Right now\n
and that's because we need to create this\n
creating our button by using this slash. And\n
dot java file. So let's open that file. In\n
to this project thing. Or alternatively I\n
see that when I do that I have a search menu.\n
activity. And if I press Enter on the first\n
java file. This is just a helpful shortcut\n
need to create the onClick method inside the\n
of this onCreate method. If you remember the\n
like this, we needed to set the access modifier\n
of the method is going to be exactly the name\n
say on Hello btn clicked. For the inputs of\n
object with capital V. This view object is\n
that we need to receive it as the input of\n
this input. And in here, we can have the logic\n
Also, if you have noticed, when I added this\n
in here, let's also minimize these imports\n
listeners for buttons. And also for that matter\n
in which may be more useful from time to time.\n
in here, let's quickly write some logic. For\n
text of my text view. For that, first of all,\n
say text view, if you take a look at your\n
the widget package has been added to our class.\n
every UI element. You have a class in Java.\n
And let's initialize it, we can initialize\n
this set content view method, this find view\n
every activity. Right now this find view by\n
the integer is going to be the ID of our elements.\n
we can say our.id. Once again, if you remember,\n
It's a special class in Java, and it will\n
in our project. So in here, I can say our.id\n
was txt. Welcome, I believe now that we have\n
operation on that. For example, I can say\n
this method previously. And inside this method,\n
Let's run the application. And let's see if\n
going to run the application on pixel three\n
that you want. Okay, right now we can see\n
is honestly oddly, but don't worry about that\n
If I click on this button, you can expect\n
text from hello to Hello again. Okay, there\n
wanted you to have another look at what we\n
which was to create your first Android application,\n
on what you have done in that video. Also,\n
in here as well. Okay, in the next video,\n
UI elements. For example, we will talk about\n
ways that we can implement an onclicklistener\n
video. In the previous video, we have seen\n
our button. There are two more ways and in\n
in our layout file, let's quickly create a\n
this constraint layout to a relative layout.\n
button. That's a wrap content and wrap content\n
For example, let's say Say hello once again.\n
through, we have seen these in the previous\n
if you're going to need an ID, let's say btn.\n
in the previous video, when we wanted to create\n
onClick attribute. In here, we need to pass\n
Java file. But in this case, I'm going to\n
to delete this attribute. Okay, let's switch\n
button. Inside my onCreate method, I'm going\n
equal to find view by ID dot btn. Hello. For\n
you can use the equivalent method you can\n
can see that we have this method inside the\n
In this case it can be new view dot onclicklistener.\n
this is an interface. Okay, now that I have\n
method has been overrided. And inside this\n
if I want to print something into my console,\n
run the application. And let's see if we can\n
here and if I click on this say hello button,\n
here. So this way, by using this set onclicklistener\n
listener. Inside the parentheses of this method,\n
method. But there is also another way, let's\n
new interface in here, I'm going to implement\n
my class. If you remember from the Java session,\n
can say implement, let's say onClick listener.\n
is coming from Android dot view that view\n
we need the first one. When we implement interfaces,\n
can do that by pressing Ctrl plus by we need\n
of this onClick method, we are getting a view\nobject.
And now we can use this view in order to create\n
on view, or V in this case, it's his name.\n
our switch depending on the ID of this view\n
case it's our.id dot btn. Hello, the exact\n
is the ID let's write some code. For example,\n
Let's also add a break and also a default\n
at the declaration of point class, and also\n
remove this btn hollow dot set onclicklistener\n
btn Hello dot set onclicklistener. This time\n
I can say this. If you remember from the Java\n
Right now we are inside this class which implements\n
is happy with accepting this as the input.\n
of all, we are setting the onclicklistener\n
interface. Whenever the user clicks on this\n
a view will be passed to this method in this\n
that why a view and a button are equivalent.\n
are creating a switch statement. In case the\n
ID of our button. We are printing this Hello\n
matter other views, we can create different\n
the application once again and let's see if\n
I click on this say hello bata we can see\n
Also, I don't like to come down in here inside\n
means that I'm going to show something to\n
of using this system dot out dot print line,\n
messages. Let's search for those messages.\n
a toast message is something like this. This\n
disappear after a period of time. Let's quickly\n
So in here, I'm going to delete this line\n
you can see that I have two options in here.\n
one is a template. Basically, templates are\n
example, in here, if I select this template,\n
been created. So we are using this test class\n
static method, we are passing a context whatever\n
on in the course. But for now, so we are using\n
called make text, we have three inputs for\n
don't worry about the context yet. We will\n
for now, just know that every activity in\n
we are inside an activity, we can pass this\n
Basically, this is going to be the text that\n
After that, we have this constant in here,\n
this is just a constant for determining how\n
if you want to see the other time periods,\n
short. Let's select length short. And after\n
method, which you can guess is going to show\n
created our toast message. And after that,\n
showing it to the user. In here we have used\n
the template, you can always create your own\n
let's select the first one. Let's say make\n
the text in here, let's say second text. And\n
toast that last long dot show. Basically,\n
can't create them with the help of the ID.\n
And let's see what would be the result. So\n
butter, you can see that some toast message\n
it will be disappeared. I think those messages\n
It's much better than this round pain down\n
in here. And let's talk about this view that\n
Instead of this view, we need to receive a\n
statement based on the ID of our button. But\n
the control key. And if you click on this\n
the CTRL key and if you click on the class\n
this text view, you can see that this text\n
means that after two times of inheritance,\n
the view class two times. So at the end, a\n
Java session when we have talked about inheritance.\n
and we created our dog class, we said that\n
is also a view. For that matter. Every UI\n
and also other UI elements that we will talk\n
proves that we can create an onclicklistener\n
well. So this onClick method is not limited\n
that when you create your own listener this\n
class declaration, you just need to create\n
For example, if I had another method down\n
button to another case. And inside that case,\n
as many methods and for that matter, as many\n
this onClick listener is one of the available\n
if you want, you can take a look at them by\n
And you can see a lot of these options we\n
you can guess the meaning of each one of these,\n
hover over our button, we also have another\n
that if we like press on a button, that's\n
of implementing the on long click listener\n
the easier way by saying new view dot online\nclick listener.
This one, you can see that in here we have\n
click method. This Boolean is just the callback\n
If you want your code inside this method to\n
write some logic. In here. For example, I'm\n
this context in here. But the format is somehow\n
an interface, we are inside this online click\n
will refer to the current object, which in\n
are not context. And we need to pass our activity.\n
dot this, don't worry about this main activity\n
about that later on in the course when we\n
just let's pass this as our context. And let's\n
period in here to Lance long. I think I need\n
let's run the application. So like before,\n
we are seeing this message Hello button clicked,\n
button. But if I press my button and hold\n
long press message. So this time, instead\n
online click listener method. You can also\n
items. Later on in the course we will check\n
say btn Hello dot set listener. And you can\n
let's move on from the event listeners. And\n
file. Before this button, I am going to define\n
width, that's a match fine this time. And\n
can see that it's something like this, if\n
also add a text in here. Let's say name and\n
Let's also center our edit text, I'm going\n
pass through. But right now we have a conflict\n
that I'm going to move this button to below\n
give an ID to this edit text. Let's say ID.\n
creating this edit text. And then in here\n
or to be a specific layout below. And I can\n
need this ad plus ID slash. That's the Edit\n
button to below our edit text. I think it's\n
top. And let's pass 20 dP, that seems better.\n
I don't like the text inside my edit text.\n
try to type something in here, first of all\n
of this text attribute. I'm going to use another\n
at the first videos of this course. Let's\n
So whenever I click on this edit text, and\n
be disappeared. Also, if we want to decrease\n
number in here, for example, we can say 250\n
remember I said that it's never a good idea\n
in different screen sizes, you cannot predict\n
once again, I'm going to change this font\n
that's done in here, I'm going to add two\n
example, I think it's better to change it\n
Adding different margins is one way but we\n
as well. So I'm going to delete both of these\n
relative layout inside the opening tag. As\n
this is our opening tag. Inside the opening\n
once again, like margins, and we have multiple\n
right top, let's just use padding in here.\n
the size of our edit text has been changed,\n
each other. Just there is one difference.\n
in the previous case, for our edit text, the\n
element, for example, from here to the end\n
depth padding, we'll add some space from inside\n
element is this relative layout itself. And\n
relative layout. So once again, margin adds\n
but the padding will add the space from the\n
them depending on your need. Let's see what\n
like a TextView, we can change the color for\n
say text color. And let's pass this color\n
now we do not have any text inside our edit\n
color will be changed to this color that we\n
by saying text style this one, we can say\n
sides at the same time, we can add a pipeline.\n
have in text views. And that's called lines.\n
need a bigger input from the user, you can\n
if I say four, for example, now our edit text\n
this case, I'm not going to use these lines.\n
number for different lines is one. With edit\n
that you're going to receive. For that you\n
one of these for example, if it's a date that\n
maybe this date time. If I'm going to receive\n
password. If it's just a simple text, I can\n
example, for different emails, and all sorts\n
if I select this text password in here, and\n
say text. You can see that when I typed the\n
you have seen this on your phone when you\n
some website, this will add some level of\n
this text email address when the user clicks\n
to type the email address. I'm not going to\n
to delete this one in here as well. And let's\n
that's enough about edit text. We have all\n
check them from here. As you can see, there\n
this button. Let's also define a TextView.\n
wrap content. Let's give it an ID, let's say.\n
text. Let's just say hello. Let's also move\n
layout below. Also, it's worth noticing that\n
example, if you're using a constraint layout,\n
This is one of the features of this relative\n
videos. Okay, in here, let's pass the idea\n
let's move it to center horizontal.
And let's add some margins. Margin top of\n
text by saying text size. And by passing I\n
with this layout file. Let's just go top in\n
reformat code in order to rearrange our code\n
the same code that I'm writing in here. Okay,\n
define all these three items. Let's say Edit\n
was name is equal to find view by ID r.id\n
text view. Let's name it txt name is equal\n
was it I think it's better to change the name\n
with our code. We are instantiating our UI\n
once again is the starting point of our application.\n
inside this onClick method. Because we are\n
whenever the user clicks on our button. And\n
for example, from inside this method, if I\n
a red warning, you can see that the ID cannot\n
this method, we do not have access to this\n
in the Java section. But the problem in here\n
So right now the scope of this TextView is\n
that we cannot use that if we want to have\n
methods, we can say something like this, we\n
of our class as different fields. For example,\n
TextView this one. And let's name it. txt\n
instantiate my TextView, for example, if I\n
this part in here is not a part of this activity\n
our TextView at all, we need to instantiate\n
is once again the starting point of our application.\n
and instantiating of our UI element, I can\n
instead of defining the whole TextView I can\n
is equal to find view by ID r.id dot txt Hello.\n
a field, I can use it in both of these methods.\n
dot txt. Inside the set text method, I'm going\n
I'm going to define this edit text as a field\n
name it really txt name. And then in here,\n
this edit text for example to the set text\n
dot get text. If you remember from the first\n
a two string method as well. We have seen\n
It's just going to generate some text. In\n
if we just pass this edit text name that get\n
you hover over this get text method you can\n
is an editable. We do not know what that is\n
and in here, we are going to need a string.\n
we need to convert the editable to a string.\n
I think after a lot of talking, our application\n
And let's see if we can see the behavior that\n
say Mesa. And let's press this pattern alone\n
And hopefully, we understand each piece of\n
earlier, I said that different UI elements\n
this button, that's also check the case for\n
the control key, and you can click on this\n
the text view, if you click on this text view,\n
you can see that it's extending the view class.\n
If you press down the control key, and if\n
it's extending the view class. Now that we\n
class, we can create an onclicklistener for\n
onClick method. If you want, we can create\n
down in here, for the edit text, I can say\n
can see that we have this option in here.\n
interface inside our class declaration, I\n
onClick method, I can create another case.\n
say Edit Text name. If that's the case, let's\n
type something. Before I run my application,\n
not going to have a conflict between different\n
Hello, the text is going to be changed to\n
And if we click on the edit text itself, we\n
on the text, we can see the toast message\n
I think that's enough for this video. In the\n
other UI elements like checkboxes, radio buttons,\n
before I finish off this video, I'm going\n
at my website@miko.org slash code. So feel\n
you in the next video. The first UI element\n
is checkbox. Let's quickly see that in our\n
to delete this TextView. And also I'm going\n
layout. Then in here, we can create our checkbox\n
and height, let's say wrapped content. You\n
added in here. If you want we can add a text\n
I'm going to enter the name of a movie. So\n
as well as let's say ID. Let's name it checkbox\n
we can check or uncheck. For example, in here\n
pass through or false for this for example,\n
be checked. Let's quickly add two more checkboxes.\n
one two more times. But this time, first of\n
say the matrix. And also let's change the\n
attribute I'm going to move this new checkbox\n
that we have an attribute called to write\n
our first checkbox, let's say checkbox, Harry.\n
left and let's pass 15 If you For example,\n
let's change the text to let's say Joker.\n
Joker. And also let's move it to the right\nof checkbox matrix.
So this way, as you can see, we can have multiple\n
by default by setting an attribute of checked,\n
say, false. If we want to center this checkbox\n
first one. For example, we can say, margin\n
But as you can see, this is not accurate.\n
another relative layout and move all of these\n
Let's quickly see how we can do that. So inside\n
another relative layout. Let's say relative\n
wrap content. Let's also give it an ID. Let's\n
relative layouts. Now, if I want, I can center\n
let's pass through. Beside that let's add\n
In other UI elements normally in here, we\n
by adding a slashing here. But in this case,\n
to finish creating my first tag my opening\n
And as you can see, this closing tag has been\n
checkboxes inside these two tags, the opening\n
them to inside those two tags. If you noticed,\n
now centered horizontally, and also they have\n
parents layout which is this relative layout\n
you can have relative layout nested inside\n
what can we do with these checkboxes inside\n
my main activity dot java file. If you're\n
to see the search menu. First of all in here,\n
going to define them as fields, let's say\n
say checkbox, Harry. In here I have two options.\n
after line. For example, I can say private\n
it checkbox matrix. Or alternatively, because\n
can add a comma in here and I can define my\n
matrix. Let's also define the checkbox Joker.\n
let's instantiate them. Let's say checkbox\n
checkbox sorry. Similarly for the next two.\n
for each one of these checkboxes For example,\n
change listener, this is the listener that\n
Once again, you can see that this is an interface.\n
change listener. Inside this interface, we\n
we receive two elements. The compound button\n
and also this is checked Boolean. So in here,\n
is checked. Let's show a toast message. Let's\n
the else case, let's show another source message.\n
Harry Potter. Before I write the logic for\n
and let's see what would be the result.
Right now Harry Potter is checked but we are\n
the onclicklistener in here is going to react\n
if I uncheck this checkbox, we can see that\n
check it. You have watched Harry Potter. But\n
we run the application without any clicking\n
here before setting this onclicklistener.\n
or not. For example, for that I can create\n
checked. As you can see, this method is going\n
it's going to check that if our checkbox is\n
to show the toast message. Let's copy it from\n
another toast message. Once again, we can\n
As you can see, when I ran the application\n
So from time to time, this is check method\n
an onclicklistener for the next two checkboxes\n
like in the previous video, instead of passing\n
listener, you can implement this listener\n
in here, and after that you need to override\n
you can pass this instead of this new listener\n
method. But once again, I'm not going to go\n
our activity main dot XML file. And let's\n
that, I'm going to minimize this relative\n
to talk about is a radio button. That's a\n
width and height, let's say wrap content,\n
Let's move on to below our relative layout.\n
was named movies relative layout. Let's also\n
25 dP and also margin top of maybe 20 db,\n
a text. For the text, I'm just going to say\n
status of the user. So that's what this text\n
say radio button married. Like checkboxes.\n
you can say checked and you can pass through.\n
you can say something like this, you can copy\n
going to be some problem with our code. Before\n
radio button. For example in here, let's say\n
to RV singer. Let's also move this one to\n
say to write off radio button marriage. So\n
is that among multiple radio buttons, you\n
between radio button and checkbox. When you\n
both when you have radio buttons, you can\n
you can see, our program is not functioning\n
to group these radio buttons. And we can do\n
radio group. Before that, I'm going to delete\n
This one. Once again, for the width and height\n
it below our movies relative layout.
Layout below ID movies rely on a margin top\n
center horizontal to true. Once again, because\n
this radio group, I'm not going to finish\n
to finish creating this opening tag by adding\n
you can see that now we have an opening tag\n
group. I can have my radio buttons, let's\n
Let's give it an ID let's say radio button\n
It's default value to checked, let's say checked\n
Let's copy and paste this one. So as you can\n
our first radio button, but it's moved automatically.\n
you can see that even though both of these\n
them is showing the checked value, so when\n
can have a checked value. For that, I'm going\n
second radio button. And also I'm going to\n
another one. For the ID, let's say radio button\n
relationship. Let's also delete this check\n
vertical. If you want, you can have horizontal\n
radio group. You can have an attribute called\n
or vertical. If I pass horizontal, you can\n
ordered, I think it's better to have some\n
quickly add some margins. Let's say margin\n
one down in here. Okay, now let's see how\n
group inside our Java file. For that I do\n
I just need to instantiate my radio group,\n
group marital status. But I believe I need\n
I didn't do that. Yes, in here I can see ID\n
I create method that's also minimize this\n
And after the checkboxes, let's instantiate\n
status, fine view by ID r.id dot, radio group\n
for this radio group by saying radio group\n
method is going to be called whenever we change\n
parentheses, you can guess I can pass new\n
unchecked change listener, which is an interface\n
One of the inputs of this method is this check\n
can create the switch statement on this check\n
in case it's our.id dot, let's say radio button\n
ID of our radio button, whichever is selected.\n
button married, I'm going to show a toast\n
it's our that Id dot, let's say radio button\n
Let's also add another case for RV in well.\n
And let's add a break. Let's run our application.\n
Right now this married is selected. If we\n
one has been unchecked. And also we have saw\n
You can see the toast message which is perfect.\n
different radio buttons inside this radio\n
doing something for example, in this case,\n
want to do something without clicking on these\n
our code. So before this set on check change\n
dot get checked radio button ID. As you can\n
radio button. And I can save that inside an\n
button. After that, I can create a similar\n
So let's say switch on the checked button.\n
and paste the cases from here. Let's run the\n
result. As you can see, we are not clicking\n
saw the Maritimes that seems to be perfect.\n
the checked radio button before clicking on\n
in this video. And that's called a progress\n
that, I'm going to minimize this radio group.\n
bar, draft content and wrap content. Let's\n
also center it, let's say center and parent.\n
And let's see what our application is going\n
can see, an infinite progress bar is constantly\n
when we are downloading something from the\n
visible or on visible, we have an option.\n
to be not visible, we can say visibility.\n
attribute for almost all of the other UI elements.\n
by default, it's visible. Let's change it\n
need to change this visibility to visible\n
to change it to gone. Let's see how can we\n
let's minimize all of the extra methods and\n
bar. Above in here, I'm going to say private\n
And then in here inside the onCreate method,\n
by ID r.id dot progress bar. I do not have\n
visibility of this progress bar. Instead,\n
the user clicks on the radio button singer\n
listener inside the switch case, in case if\n
toast message or after the toast message,\n
And I can say visible means that whenever\n
I'm going to change the visibility of my progress\n
And after the toast message. let's paste that.\n
view.com. Let's run our application.
Right now we cannot see any progress bar because\n
attribute and we have set the gun value in\n
that we are seeing the progress bar. In case\n
can guess the visibility will be changed to\n
bar. Let's quickly see that as well. So in\n
a style for my progress. But before that,\n
to visible in order to see the progress bar\n
style. If I type horizontal, we can see this\n
bar dot horizontal. Let's change the width\n
And also in here I have another option I can\n
example, I can say 30 you can see that the\n
to 30. This type of progress bar is extremely\n
of something for example, downloading a file.\n
of the file has been downloaded. You can also\n
you can see Max and can pass 100. Let's also\n
of 20 dP margin right after ntdp. Okay, now\n
see what we can do with this progress bar.\n
two lines of code, because I'm not going to\n
Let's also minimize this switch statement\n
after instantiating, our progress bar, I'm\n
from the Java session, this is the simplest\n
threat threat is equal to new threat, we needed\n
Inside this run method, I'm going to create\n
zero, i less than 10, i plus plus, for every\n
progress of this progress bar by 10. So let's\n
by as you can guess we need to pass an integer\n
that. Let's freeze this thread for half a\n
we have used this way we said thread dot sleep.\n
we create interrupted exceptions. For example,\n
And the error says that unhandled exception.\n
going to use that in here. I can say system\n
to create a try catch block. This wasn't available\n
Android dot voice, you can check that by take\n
Android dot o s that system collect is the\n
our thread, we just need to start it we can\n
we can say thread dot start. So in here, we\n
that we are creating a for loop. And for each\n
of our progress bar by 10. Also, after each\n
thread for half a second. Let's quickly switch\n
this progress attribute it was just for demonstration.\n
the progress will change to zero. Let's run\n
the progress of our progress bar. As you can\n
bar for every half a second. If you want,\n
bar at any moment that you want. For example,\n
As you can see this get progress is returning\n
your progress bar. Sometimes you may need\n
Okay, I think that's enough for this video.\n
to upload the source code at my website@maker.org\n
need and also in the next video. Finally,\n
between a relative layout, a constraint layout\n
to help you a lot with understanding the layout\n
In this video, we will talk about different\n
talk about relative layout, we will talk about\n
Let's start by talking about the relative\n
text view in my layout file. Let's also minimize\n
constraint layout to relative layout. I'm\n
we can see what we are doing. First of all,\n
from the beginning. So inside the relative\n
related to each other, it means that the place\n
layout, or maybe its parent, let's quickly\n
in action. Like before, I'm going to say wrap\n
specify a text. Let's just say hello world.\n
at the left corner of my screen if I want\n
in the previous videos that I Can center this\n
I can say center horizontal. Let's pass through,\n
this is the relativity that I was talking\n
attribute to true. We are defining relativity\n
also center it vertically. Or instead of these\n
parent. Let's also give an ID to this TextView.\n
UI element, I can place that related to this\n
here. Let's say wrap content and wrap content\n
Like before, let's say Say hello. Also, let's\n
to below this TextView, I can simply say layout\n
txt Hello, I can center this button as well.\n
And let's pass through, we can also have a\n
layout margin top and we can pass some number\n
you can also have another relative layout.\n
I'm going to define a relative layout and\n
put three text views. After that, I'm going\n
below that relative layout. So I can see relative\n
wrap content, you can say match parent. Like\n
our relative layout. For example, I can say\n
when we wanted to create our UI elements after\n
this backslash in order to finish creating\n
we are going to put some other elements inside\n
opening tag and instead of using the backslash,\n
By doing that, we also create this ending\n
now we can put our UI elements. For example,\n
Wrap content wrap content, I'm going to fast\n
Like before, we can place our two text views\n
example, we can move them to right of each\n
say to right off, let's say txt name, let's\n
for this third TextView, let's say to write\n
maybe 10 dP once again, once again, this whole\n
of our screen. If we want, we can use the\n
for this whole relative layout as well. So\n
I can say center for example. And let's fast\n
say margin top. And that's past 100 dP. You\n
a relative layout level, all of the UI elements\n
attributes. For example, in here we have centered\n
Now that we have this relative layout, we\n
better. And after that, we can move this Hello\n
that, I need to delete the center parent attribute.\n
corner of our screen and because we have set\n
as well. So in here I can say layout below\n
it was first relative layer. Let's also center\n
Center horizontal through margin top, let's\n
inside a relatively at or for that matter\n
other relative layouts as well. Some of these\n
are specific to relative layout. And if you're\n
a linear layout, and also constraint layout,\n
course, we will see that each of these attributes\n
move to the next kind of layouts, let's also\n
in here, you can see this component three,\n
This in here is showing us the hierarchy of\n
in here, we have this parent relative layout.\n
and also txt, hello, and btn. Hello. Inside\n
views. Sometimes when you have a messy UI,\n
keep track of different UI elements. Okay,\n
start talking about linear layout. Before\n
let's change the strategy of layout to a linear\n
UI elements will be placed line after line,\n
a TextView. Once again, wrap content and wrap\n
world once again. Let's also give it an ID.\n
is different inside a linear layout is that\n
horizontally or center vertically attributes\n
here, I cannot say centering parent, you can\n
center your UI elements, you can have for\n
layout. Let's move on from this part. And\n
wrap content wrap content for the text, let's\nsay Say hello.
And let's give it an ID, let's say btn. Hello,\n
any attribute to move this button to the right\n
the right of our TextView. And that's because\n
layout, all of our UI elements will be placed\n
the orientation of this linear layout so that\n
vertically. Let's quickly do that. So in the\n
to pass an attribute in here, let's say orientation.\n
have been placed vertically. There is also\n
in linear layout. Let's quickly delete this\n
For the text, let's say name. And for the\n
the margins. For example, you can say margin\n
But there is also another attribute in here\n
to give some background color for these two\n
better. So I can say background, and I can\n
that we have in our color resource. Let's\n
Let's say background, and let's fast color\n
I'm going to talk about is wait. Let's quickly\n
And we can pass any number that we want. For\n
to this second TextView. And we will talk\n
example, you can probably guess the usage\n
give our attribute so weight according to\n
in this case, the entire width of our layout\n
the first TextView 20% of the weight of the\n
you put in here. For example, in here, if\n
eight, it will work the same. Also, you can\n
have this margin top if we remove that, you\n
accordingly. So this rate was another attribute\n
this orientation to horizontal, you can see\n
to this linear layout, I just wanted to show\n
some specific attributes, for example, this\n
we are not going to use linear layout that\n
use it if you want. Before I remove all of\n
layout, you can also have other layouts, for\n
layout. Okay, let's remove one of these. And\n
that, I'm going to remove this orientation\n
Okay, let's say constraint layout. We have\n
visa dot constraint layout, this is the one\n
layout, I'm going to switch to design view\n
the design view. First of all, I'm going to\n
difference. If there is any, you can click\n
this design plus blueprint, we will talk about\n
this blueprint in a minute. Okay, for working\n
UI elements like before you can drag, for\n
that, you can see that we have four circles\n
zoom in a little bit, you can see that the\n
UI element. Let's zoom out a bit, I just wanted\n
that I'm using in here is Ctrl. Plus Plus\n
in order to zoom out. Also at any time, you\n
fit screen. It's also worth mentioning that\n
and keys for the calculator, the plus minus\n
going to be helpful in here. So the shortcuts\n
using the upper numbers. And also the upper\n
constraint layout is to constrain your UI\n
a red area in here. Similarly, we have the\n
that we need to constraint your UI element.\n
can drag one of these circles to for example,\n
added one constraint, if we switch back to\n
constraint in here. I'm talking about these\n
to the design view, we can add another constraint.\n
UI element, we can add the constraint to the\n
layout is not happy. It says that not vertically\n
add another constraint in here. And now the\n
some warning. If you want to center your UI\n
can add another constraint for example, from\n
of the screen. If you want to remove one of\n
circle and you can press the delete key, you\n
Let's press Ctrl Z in order to redo that.\n
here, you can see that you have a slider for\n
now the number says 50. But if you want you\n
it a little bit, you can see that the TextView\n
to this slider. Similar to that we have this\n
can move our UI element. So constraining your\n
way you can also add constraints to other\n
in here, let's quickly add that and let's\n
of them. Let's move it so that we can see\n
we can constrain this button to for example,\n
it moves accordingly. You can also see that\n
see all of the available targets for example,\n
sometimes it might not work, and you may want\n
have constraints with our button to the bottom\n
this TextView. If we want to make it center,\n
of this TextView. And both of these UI elements\n
margin so that we can see everything better.\n
you can see that in the attributes pane, we\n
add 32. If you take a look at this componentry\n
about this button. But we have an error about\n
the necessary constraints about this button.\n
this TextView. For example, we need to constraint\n
Like before, we can add the constraints to\n
see that when I add the constraint, this button\n
this TextView is, we want our button to be\n
one. Let's also add a margin top for this\nTextView as well.
I think 32 is not enough. So let's say 100.\n
see other kinds of constraints. So constraining\n
this TextView to the top of this TextView.\n
of this TextView is one way of having two\n
There is also another way, I'm going to press\n
we can right click on one of our UI elements,\n
you can see this baseline, instead of adding\n
can select this baseline, and we can constraint\n
time, once again, they are at the same line\n
In order to navigate through all of your layout,\n
your mouse like if you work with Photoshop,\n
both of these text views are at the same line\n
the baseline. Once again, the baseline is\n
and you can select this show baseline. Let's\n
our UI element to know both edges of our screen.\n
another line for example, if we want to move\n
to some other space beside these two edges.\n
down in here inside these helpers. We have\n
add horizontal guideline, you can guess each\n
let's add a vertical guideline. Let's zoom\n
you can see that this line has been added\n
we can move it to the right of our screen.\n
have some margin from the left side of our\n
If I click on that, it will change the margin\n
this might be useful as well. Right now the\n
our screen, let's quickly delete the left\n
we can add this constraint to this guideline,\n
once again, it might not work. You can see\n
to this guideline instead of the edge of our\n
TextView to this guideline as well. But before\n
Let's quickly delete that, sorry, I deleted\n
to this guideline and also to the edge of\n
multiple guidelines, we will add another one\n
right click on the layouts. by going to this\n
We can see that this guideline has been added\n
guideline. We also have a vertical guideline.\n
guideline. We can Guess it will add a horizontal\n
in here, if we click on that it will change\n
constrain this TextView to our guideline.\n
UI elements in a constraint layout, adding\n
example, here, we don't have much space. For\n
we want to add constraints, for example, this\n
multiple UI elements by pressing down the\n
of them, you can right click, you can go to\n
our TextView to which is the ID of this TextView\n
two, let's say bottom of our guideline tree.\n
where there is not much space to work with,\n
this constraint, you can add the required\n
need to select the path of items that you\n
guideline. Or if you want to add the constraint\n
you can select this TextView and this button.\n
of this TextView to this guideline, we can\n
move it accordingly to right and left, you\n
the UI elements move as well. But depending\n
be a slow because as you can see, where we\n
If you want, you can disable this live rendering,\n
uncheck this live rendering. Let's zoom in\n
you can see that the UI elements themselves\n
every UI element. So in some cases, when you\n
for example, some large amount of memory RAM,\n
here, you can see the difference between this\n
see that when I moved this guideline, the\n
moving accordingly. And that's because the\n
at all. It's just some blueprint of all of\n
image view to our layout, we will see the\n
from this part. Sometimes when you're creating\n
sample data, or as we might call it in programming,\n
example, right now, the placeholder for this\n
can change that, we can right click on our\n
And we can select some text, we can see that\n
the text of our TextView to Shanghai, for\n
popular choice is this date in here, you can\n
and we can have some sample data about the\n
search on the internet for sample text, you\n
select that. And we can have some sample text.\n
on our layout, we also have the Lorem text.\n
So instead of Lorem random, we can select\n
text. Before we finish off this video, let's\n
as well. I know that we didn't talk about\n
talk about that in the next video, we can\n
thing we need to set some sample data for\n
from the avatars. Right now this is the avatar\n
If you want to you can change that by right\n
select another avatar or we can select one\n
select another avatar. For example this one\n
for example to the both edges of your TextView.\n
at the attributes painting here, you can see\n
width to content, we can change that, for\n
we do that, the width of our image view will\n
which is this TextView in this case. But there\n
this layout width to match constraint. When\n
inside this constraint widget, you can see\n
on that. And once I do that, you can see that\n
for when you want to show some images from\n
or the ratio of your image. Right now, the\n
change that, for example, you can say one\n
been changed, or let's say two to one, the\n
Also, you have the same option from above\n
change this to 212. Once again, one to one.\n
you can see the difference between this blueprint\n
the blueprint view, we are not rendering the\n
are not rendering our layout. It's very useful\n
especially if you do not have the required\n
large amount of RAM, you can always go off\n
this blueprint so that you have only the blueprint.\n
in the next video. First of all, we are going\n
In this video, we are going to talk about\n
a short video. As always, let's switch back\n
constraint layout to a relative layout. You\n
just more comfortable with this relative layout.\n
And let's create our image view. This time\n
the width and height, I'm going to put some\n
Right now, you cannot see any image in your\n
not have any placeholder. But you can see\n
have some placeholder you can say something\n
you can add a sub image from your project.\n
For example, in your driver folder, you have\n
that, for example. And as soon as I select\n
image in our preview. Later on, we will talk\n
that are related to images in Android projects.\n
if you want we can later on change this image\n
our image view. Let's say ID, let's name it\n
of our path. Let's say center your parent\n
image, we have used this app driver, which\n
lives in our driver folder. If you take a\n
folder, we have seen the layout folder in\n
But beside that we have this driver folder.\n
files as well. So if you take a look at this\n
have this XML file which at the end it result\n
Inside this XML file, we have some elements\n
about them yet. We will talk about them later\n
of this XML file is this driver in here. If\n
driver folder as well. For example, if you\n
new vector asset or image asset depending\n
select this new image asset. In here first\n
right now. It's launcher icons if you want\n
see action bar and tap icons. So basically\n
First of all, you need to name your icon.\n
you will pass to your images, for example,\n
passed this IC launcher background. That name\n
the convention to name your icons with this\n
in Android Studio, you have some icons. For\n
Android icon in here, you can see the clip\n
of icons, and you can use whichever you want.\n
under this Apache License, so make sure to\n
Because I've named this icon Ico alarm, I'm\n
this one, let's select okay. And in here,\n
void. If you want, you can change the color\n
color. For example, let's pass in black.
Now you can see the alarm better. Also notice\n
And that's because in different screen sizes,\n
of these sizes. For example, if it's a larger\n
select one of these larger images similar\n
on a smaller screen size device, the Android\n
Okay, let's select Next from here. Once again,\n
inside the driver folder, multiple images,\n
will be added. And you can also see the output\n
you create your driver file. Basically this\n
Let's click finish in here. And if you take\n
see that we have this icy alarm, which once\n
Now in our activity main dot XML file, instead\n
can pass IC Allah. So this way, by adding\n
add some images to your project. Similarly,\n
folder as well. Right now we have some images\n
And also we have this IC launcher around which\n
you want to add some extra images into your\n
you can add them into this magma folder. For\n
can copy that that's a copy. And in my micpa\n
directory. And also Let's name our file. It's\n
are importing some images into our project,\n
PNG or JPG file shouldn't have any spaces.\n
any awkward cases. So the naming here I think\n
this maker dot png has been added to my lead\n
my project, I can address that from inside\n
in here instead of saying iclm, I can say\n
our map folder, we are getting a red warning\n
I'm going to delete all of this. And I'm going\n
we can see that the logo has been added into\n
added these images and drivers in our project\n
project view. And let's see if we can locate\n
So you can guess that it's in our app folder\n
folder inside Resources folder, we can see\n
again, each one of these is going to respond\n
device. So for example, if we want to locate\n
image, I believe it will be inside this week\n
But if you want to have an application that\n
the screen qualities correctly, you need to\n
and add them into your project. Right now,\n
you can see that inside this folder, we do\n
to cause any problem in order to show the\n
as there is some image with the name maker\n
user, but it may cause some bad user experience.\n
And let's talk about how you can change the\n
let's quickly run the application. And let's\n
Right now you can see that the name of this\n
at the list of your applications on your device,\n
is this rounded Android icon. This is the\n
So if you take a look at your map folder
then in here we have this IC launcher round,\n
be somehow rounded. And if you want to change\n
can see that we have this Android manifest\n
see some general information about your application.\n
file and also other XML files in your project.\n
application tags, we have two attributes this\n
are addressing the IC launcher icon for now,\n
in the devices that you are not going to show\n
quickly change this one and let's address\n
I'm going to pass me but let's run the application.\n
successfully. If you take a look at the list\n
see that the icon for this images application\n
for this video. In the next video, we are\n
also a spinner. So in the next video, we are\n
items. See you in the next video.
In this video, we are going to talk about\n
in our application. For example, at least\n
students. For that, first of all, I'm going\n
is one of the options that we can use in order\n
first of all, I'm going to close this java\n
all, I'm going to delete this TextView. And\n
layout to a relative layout. If you want,\n
more comfortable with relative layout. After\n
For the bid standpoint. This time I'm going\n
you can see that in here in our preview, we\n
These are just some sample data indicating\n
going to add a margin top, let's say margin\n
an ID. But before that if you take a closer\n
see this scroll bar at the left pane in here,\n
in case if all of our items do not fit on\n
items, we can scroll over our list view. Okay,\n
ID. I'm going to name it cities ListView or\n
now. Let's quickly switch back to our Java\n
Like before above in here I'm going to say\n
or Let's name it cities list. down in here\n
city's list is equal to find view by ID. Also\n
this find view by ID method. Instead of typing\n
you press Enter or tab you will get the whole\n
shortcuts in IntelliJ and Android Studio later\n
of our ListView, let's say our.id dot cities\n
that we want to show in our list view. For\n
of different strings. And later on, I'm going\n
I'm going to say ArrayList. This one in here,\n
is equal to new ArrayList. And after that,\n
list, let's say cities dot add. And let's\nadd some items.
In here, I'm adding all of these cities to\n
cases, the list of your objects will be coming\n
Because we didn't talk about this stuff yet.\n
going to pass them manually to our ArrayList.\n
to pass this data to your ListView. But before\n
of the adapter is to fetch the data to your\n
our adapter. There are multiple kinds of adapters,\n
is this array adapter. This is the simplest\n
here. Let's say array adapter of type string.\n
to new array adapter. Inside the parentheses\n
First of all, we need a context, which I'm\n
we will talk about context. But in here, because\n
this main activity and activities are context.\n
So by passing this, we are passing our main\n
that yet. We will talk about context later\n
a layout file for every item in our list view.\n
name of a city, we need a layout for that\n
layout, but in here, I'm going to use one\n
to say Android dot r dot layout dot, let's\n
a built in layout file in which we can use\n
view. After passing the context, and also\n
to pass the data. In this case, we need to\n
in here. And now we have our adapter for our\n
adapter is to fetch the data, in this case,\n
creating your adapter, you can say city's\n
adapter, let's say city's adapter. before\n
what we are doing in here. First of all, we\n
file. After that we have initialized it inside\n
have prepared our data in this case, we have\n
strings called cities. After that we have\n
cities array list to our list view. And after\n
our list view. Let's quickly run our application.\n
our list view. As you can see, we have created\n
that we have passed in our ArrayList. Also,\n
screen, the ListView would be a scrollable\n
simple this item that we have passed in here.\n
press down the CTRL key in Mac it should be\n
list item one you can check the layout file.\n
some attributes. Nothing special in here.\n
now if you click on one item, nothing happens.\n
these items. Let's quickly see that. So after\n
dot set on item click listener this one. And\n
item click listener. Notice that it's adapter\n
from on click listener. When we pass this\n
in which has some inputs. The one that we\n
Basically, this is going to be the position\n
see how we can use that. For example in here\n
on each one of the items. Once again, when\n
we need to pass a context. Because we are\n
in another interface, we cannot simply pass\n
in order to refer to our context. After passing\n
text in here I'm going to say cities dot get.\n
position. So this way, we are going to get\n
are using this position as the index in order\n
cities ArrayList. Also, if you have noticed\n
click method, this final keyword has been\n
a reminder from the Java session, when you\n
a variable or an object, that variable or\n
it means that you cannot change that instance.\n
of this cities, after declaring it as final,\n
object. For example, we can use this dot add\n
inside this on item click method which exists\n
needs to be constant. And this final keyword\n
it right now from here, you can see that we\n
says that your variable should be constant.\n
Also, let's add another text in here, let's\n
once again. And let's see if we have set on\n
we click on one of the items inside our list\n
see the toast message in here, New York selected\n
our on item click listener is working fine.\n
different from the onClick. listener. If you\n
it's not going to work according to every\n
enough talking about ListView. You can work\n
suggest that because in Android, we have modern\n
options. For example, we have RecyclerView,\n
a look at your layout file inside the design\n
this legacy. You can see that in here. And\n
almost no one uses ListView. I just wanted\n
reason that you may want to avoid using ListView\n
For example, you cannot customize the layout\n
a customized layout for every item. But in\n
And also, the other issue is about performance.\n
want to show in a list for example, if you\n
see the performance issue when you're working\n
better job when it comes to performance. We\n
videos from now. But let's move on from this\n
to talk about is called a spinner. Let's quickly\n
this ListView. So in here, let's say a spinner.\n
say wrap content. Let's center it horizontally\n
horizontal through margin top, let's say 50\n
inside this preview very well. And that's\n
spinner yet. Basically, this is
Winner is going to create a drop down menu.\n
see a list of different options. We will see\n
just pass an ID for our spinner. Let's say\n
better name. Also, let's move our ListView\n
let's pass the ID of our spinner. Let's initialize\n
I'm going to come above in here and say, private\n
And then in here inside the onCreate method,\n
spinner is equal to find view by ID dot, let's\n
ListView, first of all, we need to create\n
show in our spinner. For that I'm going to\n
say array list of different strings. Let's\n
After that, let's pass on data to this students\nArrayList.
Similar to when we are working with listviews.\n
create an adapter. Once again, the purpose\n
data into our spinner, we can create our adapter\n
I can see array adapter of different strings.\n
to new array adapter. Like before, inside\n
of all, we need the context. After that, we\n
screener. Once again, you can create your\n
here for the sake of simplicity, I'm going\n
dot r dot layout dot the layout font that\n
spinner drop down item. When we created the\n
list item Vaughn. But in here we are going\n
After that, once again, we need our data which\n
After creating your adapter you can see the\n
you can pass your students adapter. Let's\n
spinner looks like. You can see this winner\n
down menu. If I click on this triangle in\n
that I have passed into my ArrayList. Once\n
For example, if I click on one of these, we\n
how can we create an onclicklistener for each\n
down in here, I'm going to say students spinner\n
different from the listener that we have used\n
used set on item click listener but it's not\n
to use this set on item selected listener.\n
item select listener adapter view.on item\n
to generate two methods on item selected and\n
on nothing selected means that if you do not\n
not going to work with this method and we\n
Instead inside this on item selected we are\n
you can see that we have this position in\n
example get the name of that student. First\n
we are inside another interface we are going\n
for the text I'm going to say students that\n
Let's run the application and let's see if\n
can see that even though I never clicked on\n
because we have used this set on item selected\n
the on item click listener. I don't know why.\n
the spinner, if you try to use that you will\n
that you have is this set on item selected\n
message. If we select another item, for example,\n
in here. This is one way of showing data inside\n
not know what data you're going to show. For\n
from a web server or a database, to be precise,\n
you know that data previously in case your\n
quickly see that. So before that, I'm going\n
inside this Resources folder, we have this\n
we have this strings dot XML file, we can\n
and later on, we can pass it into our espinar.\n
the place that we put all of the static strings.\n
have this app name string, in which we have\n
see that inside this Android manifest dot\n
we click on the label, you can see that it's\n
name of our string from strings that XML file,\n
is not going to change, for example, it's\n
or the web server. So we have passed it in\n
the usages of these strings that XML file\n
in our application. But for now, let's create\n
pass it to our spinner. So inside this strings\n
kinds of items, you can create a string, or\n
The way to do that is like this, you can say\n
For example, in here, I'm going to say to\n
closing tag, I can create different items,\n
I can provide the value for example, I can\n
Once again, don't worry, if you don't understand\n
about it in the next video. Now that we have\n
to our spinner item inside our activity main\n
you have an attribute called entries. This\n
these add airy students this is the address\n
file that's passed that and as soon as I pass\n
data in our spinner. So now that I have passed\n
don't need to pass them in my jar file dynamically.\n
of code, for example, from here to top in\n
inside this on item selected method. And that's\n
If you want to show the name of the student\n
the students array list, you can use another\n
create a new toast message. For the text.\n
dot let's say get selected item. You can see\n
let's say get selected item after that we\n
another level of conversion in order to convert\n
After that, let's say plus selected once again\n
what we have done. First of all we have created\n
it to our spinner statically and after that\n
set on item selected listener. Inside the\n
toast message. And we are getting the value\n
dot get selected item method. Let's run the\n
same behavior. You can see that we have some\n
example, you can see the toast message Brad\n
fine. So far, we have talked about different\n
dot XML, which is a layout file. In the next\n
of XML files, for example, this strings that\n
we have other kinds of XML files. In the next\n
So far, we have talked about different layout\n
Resources folder inside the layout folder.\n
main dot XML file, in which we have defined\n
activity. But in Android, there are a lot\n
of the previous video, we have take a look\n
days. Let's talk a bit about that strings\n
this Resources folder inside the values folder,\n
you remember, I said that this is the place\n
of your application. Let's quickly see what\n
layout file, if I define a TextView, we have\n
Let's say txt Hello, let's go to our Java\n
Let's say private TextView. Let's name it.\n
let's curricular initialize this TextView.\n
text of this text a fellow manually. For example,\n
And if we pass Hello, you can see that we\n
highlight says that this string cannot be\n
If you want, you can have some more information\n
you can press Ctrl plus f1. And you can see\n
this in here means that this text is going\n
example, if you have an application that has\n
going to be the same in all of the devices\n
warning says you can define this text inside\n
how we can use this strings dot XML file in\n
I'm going to define another string, the way\n
After that, we need to name our string. For\n
hello. And for the value of this string, I'm\n
to my text view inside my java file. Instead\n
string. This get a string method like this\n
every activity, we can use that because we\n
inside these practices, we can address our\n
string, dot let's say hello, right now the\n
example, we are just going to show hello to\n
is to create another strings dot XML file\n
here, I can right click on my values folder.\n
to name this new XML file exactly strings,\n
here it should be exactly the same. And in\n
about few of them in here. But the one that\n
Let's select that. And let's add it to this\n
is going to be useful for when you want to\n
For example, if you know that you have some\n
application this way for those users as well.\n
you can see that we have this the German D\n
we can select a specific region, we know that\n
let's select Germany. And let's press OK.\n
you can see that now you have these strings\n
dot XML file, the names are exactly the same,\n
users. Right now, this strings dot XML file\n
can define some strings in here. For example,\n
as well. Let's see a string. Let's name it\n
would be exactly the same name that you have\n
If you remember in here, we have this string\n
hello as well. Now let's pass on value for\n
of Hello is Hello, I believe. So inside this\n
we have a string called Hello. But the value\n
had inside the default strings dot XML. Now\n
file, because inside our main activity, we\n
addressing our Hello. If some German language\n
TextView will be different in different languages.\n
see the difference. Right now the language\n
that, we are seeing this Hello text. But if\n
say German, we should see how though, let's\n
change the language of this device. And let's\n
go to the settings. down in here inside the\n
input. Let's go to languages. And let's add\n
or its equivalent storage, we need to select\n
we need to make the storage as the default\n
to above this English. And now you can see\n
to Deutsch. If we run our application, once\n
time, you can see that we are seeing hollow\n
of code, we now have an application that looks\n
are the strings dot XML file is extremely\n
you can add another string file. For example,\n
click, we can say new value resource point.\n
again, we can select this locale. And if you\n
you can do the same process. After creating\n
your application for another language, you\n
a translator and ask him or her to change\n
As simple as that you can localize your application\n
we also have an error in here this URL is\n
do not have an equivalent string for this\n
in different languages as well. But we are\n
Okay, let's close all of these. And let's\n
applications. The other XML file that I'm\n
file. Once again, it's placed inside this\n
You See, that's right now we have three colors\n
the place that we pass all of our static colors.\n
here for that we can come between these resources\n
color. For example, let's say blue. And for\n
we can get that value by searching for HTML\n
For example, in here, if we want a blue color,\n
value from here and we can paste it in our\n
here we have this blue color. Now that we\n
places of our application. For example, inside\n
defined this TextView, we can change its color.\n
and we can address our color. For example,\n
is referencing our colors that XML file this\n
of our text has been changed to this light\n
on the internet, you can also define them\n
color accent color. Let's copy that. Let's\n
But for the value of this white color, I can\n
void color. For example, let's select this\n
color without searching the internet. We can\n
Okay, there is not much more to these colors\n
you can define new colors. Let's talk about\n
which is this styles dot XML. But before that,\n
styles dot XML. Once again, it lives inside\n
dot XML file is the place that we define the\n
one style in here. Later on, we will see that\n
style is app theme. But if we want we can\n
value of some of these colors if we want.\n
also define multiple styles. For example,\n
it down in here. We need to name our style\n
And let's override the previous style. For\n
here, which you can guess it's implementing\n
here. If you want, first of all, you can change\n
at the other ones. Let's say light.we have\n
to use in future videos, we have these dialogues,\n
instead, if you want, you can change some\n
parts of our application, we may use this\n
of this color primary is right now, this value\n
you want, you can change that, for example,\n
You can see that now the color primary in\n
one is this dark green for the second one\n
this customized app theme slide you can pass\n
application. It means that different activities\n
application can have different styles. For\n
some of them may not have that toolbar if\n
that how we can do that. Also we will talk\n
worry about activities if you don't understand\n
place that you define different styles for\n
this styles dot XML file later on. In the\n
design, but for now let's move on from this\n
The other XML file that I'm going to talk\n
manifest dot XML file. I believe this is the\n
Basically, this is where you define the general\n
you can see that we have this manifest tag.\n
we have seen this icon and round icon previously.\n
want to define different icons for your application.\n
the name of your application that is going\n
theme for your application, which as you can\n
style, if you want, you can pass your customized\n
in your application. But in here, I'm not\ngoing to do that.
Right now, inside the application tag, you\n
main activity. So basically, every activity\n
inside this application tag as well. This\n
because when we have created our application,\n
But if we don't select that template, one\n
inside this manifest file and declare our\n
this intent filter tag, don't worry about\n
in the course, I believe in the broadcast\n
you can guess the user of this intent filter\n
this main activity is the launcher activity\n
all of these yet. These are just some basic\n
So beside activities, you need to define three\n
So in every Android application, we have four\n
broadcast receivers, and services. We will\n
But these are the four main components of\n
to be declared inside the manifest file. So\n
important. It contains all of the important\n
back to this manifest file a lot during the\n
all of these new stuff that we are seeing\n
going to talk about is menus, let's quickly\n
inside the Resources folder, you can create\n
default, you do not have that directory like\n
files, we need to create that directory, we\n
can say new directory, it's very important\n
you can see that we have this menu folder\n
you can say new menu resource file. This way,\n
let's name this menu file main menu. Let's\n
it look like. Let's switch to text view. In\n
Basically menus are useful for when you want\n
And the way to do that is to come inside this\n
say item you can define multiple attributes\n
and you have to create that is this title.\n
can pass a title for your menu. For example,\n
some menu has been created in here. later\n
our main activity to have some sort of menu\n
that I have in here is ID for example, I can\n
for our menu item. But I believe we do not\n
An icon let's quickly create some icons in\n
create different icons, we can right click\n
we can create icons. In the icon type, I'm\n
example, inside this clip art, let's search\n
one icon in here, let's add that. Let's change\n
the color to black. Let's add another icon\n
before. Let's name this one icy alarm.
Let's search for alar. Color is fine, let's\n
two icons, we can pass them in our menu file.\n
Let's pass our settings icon icy settings.\n
in here. But if you want to see that you can\n
as action. So we have some values for this\n
it means that we always want our menu items\n
options. For example, we have this if row,\n
there is room for this menu item. We have\n
the menu items like this and never show them\n
now to always. And let's create another item\n
title is mandatory. And also we are getting\n
again, it says that you need to define the\n
this is for the localization purposes. And\n
title in your strings dot XML file. In your\n
But in here for the sake of simplicity, I'm\n
this warning. So let's pass a title in here.\n
Id let's say alarm menu. After that, let's\n
set the show as action attribute for this\n
you want. But I think for this simple menu\n
we have created this menu file, let's see\n
main activity. Let's close this file. Once\n
folder inside the menu directory that we just\n
main activity, you need to open the main activity\n
method in here. So because we are extending\n
we have some methods that we can override\n
If you come outside of this onCreate method\n
of all of the available methods you can see\n
we need in here is called on create Options\n
you can see this method in here let's select\n
of all I'm going to delete this statement\n
menu and I'm going to create or inflate my\n
class in here. Let's name it inflator is equal\n
is like this, find view by ID method. It's\n
with the help of this inflator, we are going\n
to our inflator we can say inflator dot inflate.\n
to address the menu font that we just created.\n
menu, the menu that we just created. The second\n
to this method. That's fast that you can see\n
This Boolean is indicating that if we have\n
we have inflated our menu and after that we\n
that we need in order to inflate or create\n
application. And let's see if we can see our\n
You can see that in our activity, we have\n
alarm icon. We can also set an onclicklistener\n
see how we can do that. So we need to override\n
menu method. If we press Ctrl plus Oh, and\n
this method in here if we select that, we\n
keep this super statement we will talk about\n
the input of this method, we are getting a\n
to click on. And we can use it. For example,\n
our switch statement. So our switch statement\n
ID. If you remember in our menu file for different\n
quickly see that in our main menu dot XML\n
items. And in here, we are going to act upon\n
Let's say in case it's our.id. That settings\n
let's say toast. For the text let's see settings\n
the toast message in here, instead of adding\n
specific case, we can return something. Once\n
this method is a Boolean as well. This Boolean\n
to this item successfully or not. In here,\n
to return true. So let's say return true.\n
in case it's our that Id does alarm menu.\n
message. Let's say alarm selected. In Here\n
world application, you may want to navigate\n
But more on that later on when we know about\n
showing the toast message, let's return through\n
case. In the default case, I am going to return\n
in other items besides these two. So do whatever\n
I can call this super segment from here, I\n
we run our application. Let's review what\n
on options item selected method we are getting\n
to create a switch statement. In case the\n
are showing this source message setting selected.\n
another toast message. But in the default\n
two, we are passing the job to the parent\n
see if we have set the listener successfully.\n
icon, you can see that settings selected.\n
selected. It seems like you have done a good\n
Okay, I think that's enough for this video.\n
our talk about other kinds of XML files available\n
Let's continue our talk about different XML\n
a look at different XML files for example\n
inside our mipmap folder. We have seen a strange\n
a look at menus and also our manifest file.\n
now our main activity has only one layout\n
want, you can create more layout files for\n
layout is for the portrait mode, if you want,\n
let's say landscape mode. If you don't know\n
let me quickly show that. So right now, this\n
the rotation of our device, and this is going\n
the rotation of this device. Let's go to the\n
this is the option, this auto rotate, we need\n
device, you can see that now we have a different\n
work. But if you have a complex lab file that\n
rotations, you need to create two separate\n
for the portrait mode and one for the landscape\n
another layout file for this main activity.\n
folder, I can right click by selecting new\n
file, or alternatively, inside this activity\n
on this icon, you can see that we have this\n
you can create a landscape variation for the\n
do that, I'm going to add another text. And\n
this layout file. So I'm going to move this\n
quickly add some constraints. As I mentioned\n
other, you can always select both elements.\n
to constraint and add constraint from here,\n
I'm going to add some margins of let's say\n
going to be the look of my application in\n
after each other vertically. But in the landscape\n
each other, let's quickly create a variation\n
create landscape variation, you can see that\n
inside the activity main folder, we have this\n
mode, and the other one, which is for the\n
change this landscape for example, I'm going\n
Let's delete all of the previous constraints.\n
this TextView the left constraint. Let's place\n
Also, another point in here that you may find\n
elements, for example, horizontally, you can\n
by right clicking on the item, and by going\n
you can center your items horizontally. So\n
mode, the layout for the landscape mode, and\n
mode. Now if I run my application, I should\n
landscape mode, the two texts are beside each\n
mode, the two texts are vertically after each\n
in here and selecting create landscape variation,\n
main activity. But this is not the only option.\n
if you want to activate a nice theme for your\n
quickly see how we can create that. So in\n
here I have all sorts of options. For example,\n
activity, we can select this night mode, we\n
night mode. That's a night. Let's create this\n
thing. Now inside this activity main folder\n
dot XML files, the middle one is for the night\n
example, you can change some colors, but I'm\n
to ignore this layout file for the night view.\n
for our activity. So once again, I can go\n
you can see that we have all sorts of options.\n
in which we can create different layers for\n
on the user's device. Let's add this to this\n
a number. For example, if we want our application\n
put 21 in here, and we can create the layout\n
inside activity main folder. Now we have this\n
for the version 21 of the API. This way, you\n
can change them if you want. Before I finish\n
point of XML files in Android. let's right\n
new layout resource file. And let's see what\n
XML file, I'm going to say trademark. And\n
to let's say, relative layout. Let's select\n
this TextView, you can see that we have this\n
whenever you want to reuse some layout file,\n
dot XML file in which I'm going to put an\n
creating this layout file, I can reuse this\n
in multiple activities of my application.\n
layout files. First of all, let's design this\n
TextView. Or before that let's define an image\nview
let's say 15. dp for the width and height.\nLet's give it an ID.
And for the placeholder, I'm not going to\n
I'm going to use this IC launcher background\n
define a TextView. In here, wrap content and\n
developed by me Sam. After that, let's move\n
let's say to the right of logo. Let's add\n
this text a little bit. Let's say italic,\n
this TextView. Right now the width and height\n
is match parent in here, I'm going to change\n
wrap content, you will see why when we use\n
another attribute for both of these elements.\n
for both of them, let's say through between\n
is our simple layout file. In here we are\n
If we want to show this layout file in multiple\n
include tag include tag is very useful for\n
don't want to write the exact same file twice.\n
file. And let's see how we can use that trademark.\n
to say include, and I can add a layout attribute.\n
file. In this case, it's at layer slash trade.\n
file inside this layout file. If you want,\n
can see that I can select this whole layout\n
my layout file, you can see that it won't\n
again at the top of my screen. And that's\n
height of this layout, right. The way to do\n
in here for my whole layout file, I need to\n
So for example for the layout, which I'm going\n
I'm going to say wrap content This way, you\n
file, we just need to override the width and\n
two more constraints. I can use this trademark\n
parts of my application that can be useful\n
tag, you may want another tag. Let's quickly\n
sometimes you may see merge this tagging here.\n
it's avoiding redundancy. Let's talk about\n
elements have no idea about about their parents,\n
used inside relative layout, a linear layout\n
they don't know about the parent, you can\n
in here. But if you know for sure that where\n
example, if you are going to use this layout\n
to write the linear layout. Once again, you\n
At the time of rendering your layout file,\n
two elements will be placed inside the parent\n
when you know for sure, that's where you're\n
tag can improve the performance when rendering\n
change this to a relative layout. Okay, I\n
XML files in Android, we have others as well,\n
course. But for now, I think it's enough.\n
the material design library, see you in the\nnext video.
In creating Android applications, designing\n
layout will impact the number of downloads\n
also it will impact the user's feedback. But\n
if you're like me if you are more interested\n
we have material design as a guideline for\n
Design also introduces some new components\n
check the material design website. And let's\n
website for material design is material that
if you go to this Developer tab in here, you\n
you can also use material design for iOS app\n
and also you can use it with hybrid development\n
As I said, Material Design consists of two\n
designing your applications. Also, besides\n
that you can use in your application, we will\n
But before that, if you take a look at this\n
to check the guidelines for typography theming,\n
if you take a look at this material design\n
guidelines. Basically these guidelines are\n
a beautiful application. Basically, these\n
to follow when you are designing different\n
and the guidelines. In here we are not going\n
to take a look at the components. If you go\n
we have a lot of components. We are familiar\n
we have seen different buttons and checkboxes.\n
that later on. We will see a lot of these\n
few components that we already know. For example,\n
this image, you can see that we have four\n
are somehow different from the buttons that\n
Basically, the main difference is in the styling\n
have all sorts of other components. For example,\n
We have also some documentation and guidelines\n
to check the guidelines for designing a checkbox,\n
can see some guidelines. So make sure to check\n
use these components in our applications.\n
this video, we are not going to vote with\n
we will be coming back to this web page and\n
of all, we are going to start with material\n
action button. This one in here. We will also\n
like a snack bars. Later on in the course\n
up bars, and also things like tab layouts\n
implement these maffeo buttons in our application.\n
in your application, you need to add a dependency\n
dependencies in our applications yet, but\n
I said that Gradle will combine all of the\n
the static resources in our application. And\n
the third party libraries that we use in our\n
are going to use in here and later on Gradle\n
is this material design. So we need to add\n
with the help of Gradle. In order to add the\n
Developer tab. After that, you can select\n
you can go to this getting started. And from\n
need. In this page, you can see a step by\n
design library into your project, make sure\n
what they are saying is that, first of all,\n
in your project. Let's see where that is in\n
Gradle script inside this build that Gradle.\n
repository, Google repositories has been added\n
projects. But if you don't see this Google\n
after adding the Google repository is to add\n
dependency from here, and you can add it to\n
need to go to this build that Gradle module\n
close this one. And let's also minimize all\n
inside these dependencies in here. For example,\n
other dependencies. Let's face that in here.\n
right now we have this version tag in here.\n
check the internet for the latest version\n
of Andrew the studio. Right now I'm getting\n
you can see that the latest version available\n
I'm going to say 1.1 point zero. After adding\n
sync now. And after that Gradle will download\n
library files from the internet. And it will\n
click on the sync. Now before that, make sure\n
somehow fast. And now we can use material\n
these dependencies, you can see that by default,\n
we have this constraint layout, we have these\n
these app compat dependencies which help backward\n
Okay, now that we have added this material\n
But before using them, I'm going to add a\n
that. Let's also enable this preview. And\n
So in here, I'm going to save button, let's\n
let's say Say hello. Let's also change this\n
let's center our button. You can see that\n
Now let's implement material theme. And let's\n
So for that, I'm going to open my project\n
folder inside the values folder, we have these\n
we have this app theme style in which its\n
here. If we want to implement Matthew, your\n
do that. And the theme in here is going to\n
another theme called theme dot material components\n
a look at that in a minute. But in here, I'm\n
components. So for that, I'm going to delete\n
of the values from inside these material components\n
the past theme of this afternoon. But right\n
XML file, you can see that we are getting\n
style of our button. This is good for a night\n
parents theme to a light theme so that we\n
here. And if we switch back to our activity\n
seeing this beautiful light theme out button\n
the font is somehow different. And also the\n
We didn't change anything for our button elements.\n
as the parent theme of our application, all\n
We can also customize this button for example,\n
button. But before that, let's quickly add\n
that XML I'm going to add a new color, let's\n
the name to let's say orange. For the value,\n
in our activity main dot XML file, if we want\n
to the orange, we can say background tint\n
orange color. We can also change the text\n
necessary, I just wanted to show you that\n
this color. As you saw on the material design\n
Let's see other slides as well. For example,\n
material button, you can see that we have\n
see that this is basically this style that\n
Let's remove that. And let's see others, we\n
button. If you take a look at that, you can\n
to some outline button. Sometimes this might\n
quickly see that. This is the one material\n
will change our button to a text button. Sometimes\n
with the default case. So I'm going to delete\n
that using material design is very easy. Basically,\n
our project inside this, like build that Gradle\n
we change the parent to this team, that material\n
all of the elements from inside the material\n
into your layout file, for example, a checkbox\n
design library will be used. Okay, let's move\n
of the components that we don't have in our\n
design library, the first of those components\n
floating action button. Let's delete this\n
button. So in here I can say floating action\n
we have this floating action button and we\n
Let's use the first one for the width and\n
as soon as I do that, you can see that we\n
action button is going to be floating on our\n
the page, if you want, you can change the\n
move it to down below in here. For that I\n
so far. For example, I can see a line parent\n
that as soon as I do that its location will\n
can also use another attribute called align\n
of our screen, let's say through and now you\n
margins. Let's say margin. In here, we have\n
Or alternatively, we can use this version.\n
will get a warning. Let's quickly use that.\n
here, I'm going to say 20 dP, you can see\n
at this, it says that it's better to use margin.\n
the languages it starts from right. So for\n
in that case, this floating action button\n
And if you add a margin, right, it's going\n
of the screen. For that reason. It's better\n
and let's fast 20 dP, you can see that we\n
need to add a margin button. That's a margin\n
add an icon for your floating action button\n
driver folder and let's add it for our floating\n
on our driver folder. Let's select action\n
sign in here. Let's search for add. And let's\n
And also, let's change the color. I'm not\n
I'm going to use this custom color. And I'm\n
is on white. So let's say choose, and let's\n
for your floating action button. But for some\n
which is the attribute to pass an icon for\n
I added this dependency in my project, I need\n
option is to rebuild my project. Or the better\n
your cache and restart Android Studio.
Let's select that, let's see, invalidate and\n
I can use the source attribute. So inside\n
source, this 100 source, and I can pass my\n
that, this icon will be added to my floating\n
the color of this floating action button.\n
color that we have defined a few minutes ago.\n
here, and I can pass color orange, you can\n
Also, you can see that we have some sort of\n
you want, you can also change that. The way\n
background tint. And this way, you can pass\n
pass avoid color. First of all, you can create\n
after that pass that or alternatively, you\n
directly in here. For example, I know that\n
pass that, you can see that we have a void\n
border of this floating action button is now\n
is for the background color of your floating\n
tint is for the border of your floating action\n
anything. Let's quickly see that you can see\n
repo color, and pass a color. For example,\n
color is the color of the floating action\n
application. And let's see that you can see\n
button at the bottom of our screen. And if\n
That white color is this rainbow color. Beside\n
of this top bar has changed as well. This\n
theme in our application. Later on, we will\n
we work with material design. We will implement\n
But for now let's talk more about this floating\n
for this button if you want as well. But for\n
action button inside our main activity dot\n
can say private floating action button, this\n
action button package. Let's name it FA B.\n
our on create method. Let's say FA v is equal\n
to give an ID to our floating action button.\n
ID, let's just name it FA B, let's say our.id\n
onclicklistener is fine in here. And we can\n
a toast message. Let's say fab clicked. Let's\n
the toast message. You can see that you're\n
There are also other ways of using this floating\n
use a combination of floating action button\n
see that we can implement a beautiful style\n
But more on that later on when we talk about\n
enough for this video. In the next video we\n
design library. We will talk about snack bars\n
In this video, we are going to talk about\n
those components is snack bar. Before we start\n
does it look like. So if you go to material\n
here, you can see a snack bar. Let's see that.\n
a lot like a toast message. But the style\n
the snack bar, you can have a button that\n
your snack bars to be indefinite, it means\n
clicks on this action. Also, you can style\n
change the color of this text and also the\n
later on in the course snack bars are extremely\n
In order to use the snack bars. First of all,\n
into your project. So let's go to this Developer\n
the documentation getting started. Let's copy\n
Gradle scripts build that Gradle. Let's quickly\n
hover over this, you will see the latest version,\n
dependency. First of all in my layout file,\n
add a button. And also beside that I'm going\n
of all, you may have noticed some changes\n
the previous video. That's because I have\n
differences. Don't worry about that we will\n
For this video, let's just implement our snack\n
Android Studio is that you no longer can see\n
want to go to your text, you can go to this\n
about these differences. Let's give an ID\n
going to name it parent. Later on in this\n
ID to this constraint layout. Let's also go\n
Before that let's delete this text here. Let's\n
its text. I'm going to change it to show snack\n
of my application so that we can see the material\n
previous video in our values folder inside\n
the panel theme here. I'm going to change\n
light. If you switch back to your layout file,\n
buttons in my java file. First of all, I'm\n
layout and also this button. Let's quickly\n
Let's name it parent. And also private button.\n
inside the onCreate method. Let's initialize\n
ID r.id. That parent potential snack bar is\n
its ID was button after that set onclicklistener\n
bar dot set onclicklistener new onclicklistener\n
So let's say show snack bar. Let's quickly\n
show snack bar. We don't need any input.
And here is how you can show snack what you\n
a new snack bar you can use this static make\n
This make method needs three inputs. First\n
layout that we are going to show our snack\n
is a constraint layout. And as you saw I have\n
the reason I gave an ID to my constraint layout.\n
I need to text that I want to show in my snack\n
a snack bar. The third parameter in here is\n
you want to show your a snack bar. And you\n
say, a snack bar, that you have three constants\n
also left indefinite. The long and short are\n
you will show your snack bar indefinitely,\n
on that action button. Let's select this one\n
you can call dot show method in order to show\n
simple snack bar. And we don't have any action\n
click on this button, we should see our snack\n
bar. And we don't have any action beside that\n
because we have past this length, indefinite\n
Let's quickly change this constant to length\n
we show our snack bar, you can see that it\n
now let's see how we can add an action to\n
to change this constant to left indefinite\n
going to call another method. That method\n
need a text in here, this is going to be the\n
you can say retry in here. After that you\n
listener. This is going to be an interface.\n
we want when the user clicks on this retry\n
going to show a toast message. Let's say retry\n
As you can see in here, now we have this retry\n
indefinite. But if we click on this retry,\n
we will see a toast message. Let's also see\n
two texts this retry and also the color of\n
again before the show method in here, I'm\n
set action text color in order to change the\n
pass your colors in two different ways. First\n
color resources, if you remember in your project\n
folder, you had these colors, that XML file\n
can address one of these corners inside your\n
get color. And after that our dot color dot\n
you have noticed, we have some colors that\n
You can see that we have these colors as well.\n
primary in here, you can see that we are getting\n
can use this method in API level 23. and higher.\n
without seeing this error. Let's we can see\nthat.
Let's say get resources. This phone dot let's\n
address your color, you can say our color,\n
see the other way. Instead of using the resources\n
for example, instead of this whole method\n
which is coming from Android dot graphics\n
color with the help of this color class. So\n
you can also use this class. Okay, now let's\n
of our snack. For that I can say that set\n
to pass a color you have two options. In this\n
yellow. Let's run the application and let's\n
or not. Let's show our snack bar. You can\n
And also the color of our action button is\n
the snack bar. Later on, we will use snack\n
component that I'm going to talk about is\n
does it look like in material that I have.\n
this cart, you can see your cart views. Let's\n
view looks like. You can use it to, for example,\n
you can mix UI elements in form of a cart.\n
for your cart view. Also, you can have some\n
shadow or elevation to be precise beside your\n
to implement the actions we will do that later\n
implement a simple cartoon in our application,\n
in our project, so we can add the cart view\n
close this style and colors. In my layout\n
below this button. Let's switch to the split\n
going to define my cart view, let's say material\n
view, you also have a native cards view. But\n
want to use the material card view, you can\n
the dependency from the Android x libraries\n
this material cart view. I'm going to enter\n
I'm going to say 100 dP, I think that's fine.\n
has an odd shape, I think it's better to change\n
I'm going to say card view. After that inside\n
But before that, let's quickly concentrate\n
of all, I'm going to define a relative layout.\n
parent, the parent is this card view. So we\n
inside this relative layout, I'm going to\n
put a TextView wrap content and wrap content.\n
text, let's just say hello. Let's also change\n
And let's pass both beside that let's increase\n
this TextView, I'm going to define an image\n
can have multiple UI elements for the width\n
for the height, let's say match parent, I'm\n
TextView. So let's say layout below. But before\n
Let's say ID. txt Hello. Let's also add a\n
margin top, let's say 10 dP centered horizontal\n
say source. I'm going to pass this IC luncheon.\n
the cardview. Beside that in their current\n
well. For example, if you want to make the\n
have this option corner radius, called corner\n
right now you may not see the difference.\n
the corner radius You can also change the\n
not enough. The other option that we have\n
give some 3d shape to our card, we have some\n
to say five up, you can also define this card\n
file. Let's quickly do that private cart view.\n
We have this card view which is coming from\n
material card view which is coming from the\n
going to use this material called view but\n
style. Let's name it card view. And down in\n
initialize it Let's quickly set an onclicklistener\n
Beside that, you can see that we have a lot\n
later on in the course, set onclicklistener.\n
the application. And let's see what does our\n
something like this, which is not that good.\n
We will do that later on in the course. Specifically\n
of recycler view and card view for its items\n
We will see that I believe in the next video.\n
corner radius and also we have this elevation\n
Beside that later on in the course, we will\n
That means that we will have some button in\n
on that view, expand our cart view and we\n
for our item in our cart view. Okay, I think\n
I just wanted to show you how you can create\n
In the next video, we are going to start talking\n
have seen list view for showing different\n
option to show lists of different items. In\n
to see how we can use recycler views. See\nyou in the next video.
In this video, we are going to talk about\n
option for showing a list of different items\n
can see, I've updated my Android Studio and\n
about recycler view, I'm going to show some\n
Android Studio, I strongly suggest that you\n
can do that by going to this Help menu. down\n
And if there is any updates available, you\n
in here is Firebase services, we are not going\n
you can see that I've also have some updates\n
update them after this video. But for now,\n
remember from the installation videos, I've\n
stable channel. If you're not sure about your\n
going to this file tab in here by going to\n
you can see that my updates are being checked\n
as well. These other channels are for preview\n
developers to check new features in Android\n
Android team. But for you for the starter,\n
a stable channel. The first thing that is\n
Studio is the way you go to full screen, you\n
menu. And by going to appearance. From here,\n
this option was somewhere down in here. Let's\n
you can probably see in here is this component\n
There are not much changes in here just this\n
above in here. You can see that down in here\n
mode. Instead of in here we have three options.\n
can also select this one to go to the text\n
splitter mode. As you can see, it acts like\n
view, but there is a difference. Before that\n
From here from inside this splitter view,\n
if I select this button, I can see the text\n
of this button and also I can see all of the\n
to be helpful, especially if you're using\n
to minimize this attribute pane. You You can\n
attributes, you can also enable this palette\n
layout elements. And you can drag them directly\n
Once again, this is going to be helpful if\n
thing that you can see in here is this resource\n
Studio 3.5. But there has been some improvements\n
this resource manager, you can see all of\n
Previously, if you wanted to see different\n
have go to this project training here. And\n
checked your drivers. Now with this resource\n
more easily. Also, beside that you can see\n
mipmaps, the strings, and also if you click\n
sorts of resources in your project. Also,\n
from here. For example, right now, in our\n
its source is this IC launcher background\n
to change this to this IC launcher mipmap\n
and we can paste it in here, you can see that\n
Similarly, we can do the same thing for the\n
resources, we have this app name string, we\n
Hello, we can see that the text has been changed.\n
this resource manager can be useful. The other\n
of Android Studio is the font of my code.\n
to change it to the previous font that we\n
go to this file inside the settings. You can\n
the font. For example, I think I'm going to\n
it is the previous font that we had when we\n
besides Android Studio, I've updated my Gradle\n
can go to your project menu, you can go to\n
about the Gradle. First of all, if you take\n
you can see that we have the latest version\n
if you go to this build dot Gradle project\n
latest Gradle tools version. So beside Android\n
you wouldn't see any difference when you update\n
fix some bugs, and also it may improve some\n
to keep everything updated when you're working\n
this part. And let's talk about recycler view\n
close this project. And I'm going to create\n
Studio project. Now that we have in here under\n
as well. For example inside this TV, you can\n
operating systems, or for different devices,\n
are not going to work with them. Like before\n
name this project recycler view. Or let's\n
that in here, we have this new option in here.\n
libraries. So basically, before Android x,\n
backward compatibility is in older devices.\n
of Android X was mandatory. But now in here\n
are going to use this legacy support libraries\n
this option. Okay, let's create our project.
And let's see how we can use recycler view.\n
we can go to our activity main dot XML file.\n
option in here but before using it, we need\n
You can click on this download option in here\n
gradle file. Or if you don't want to add it\n
view dependencies and add Manually into a\n
let's quickly open our Gradle scripts build\n
dependencies, you can see that we don't have\n
view by clicking on this. You can see a warning\n
say okay, it seems like we have added recycler\n
gradle file. And then in here, you can see\n
highlighting here, this is not the latest\n
to check the internet for the latest RecyclerView\n
you have version 1.1 point oh available. So\n
let's sync our project. Okay, now that we\n
can add it to our layout file. I'm going to\n
I'm going to minimize this resource manager.\n
layout to a relative layout. After that's\n
And let's add a recycler view. So you can\n
For the width and height. Let's say match\n
layout. Let's also give you an idea. Let's\n
I'm going to show a list of different contacts\n
creating our recycler view. And if you enable\n
you can see that we have these options inside\n
some padding to this parent relative layout.\n
say padding, and let's say 10 dP. That seems\n
our recycler view in our Java file. So inside\n
all, I'm going to say private recycler view.\n
view v jet. Let's name it contacts recycler\n
method, let's initialize it. Contacts, recycler\n
recycler view. When we have worked with ListView,\n
our ListView, we could have create an array\n
our array adapter to our list view. But when\n
our own adapter. Creating your own recycler\n
code that you have written so far. But we\n
Before creating our adapter. We also need\n
used ListView. For every item in our list\n
view, we need to create that layout as well.\n
folder inside the layout folder, I'm going\n
going to name this phone contacts this item.\n
to a relative layout. Okay, let's create our\n
If you remember from previous videos, I said\n
you have all sorts of flexibilities. In designing\n
at more complex layout files. But in here,\n
Let's switch to the split view so that we\n
Wrap content and wrap content. For the text,\n
view, we are going to change this text view.\n
let's say txt name. I'm also going to change\n
content because we don't want to occupy the\n
view. For that, let's change this font to\n
in here so that we can see it better. And\n
And that's past 10 Up. Sorry for that. Let's\n
will see how it can be useful. Let's just\n
be the layout file for every item in our recycler\n
this item dot XML file, we can create our\n
create a Java class in our project. So inside\n
Let's name this class contacts, recycler view\n
see what do we have in here. So first of all,\n
inner class inside this class, we will see\n
needs to be public, let's say public class.\n
the convention. This view holder class needs\n
class in here, but as you can see, we are\n
we need to create our constructor. Let's quickly\n
inner view holder class is going to hold the\n
For example, in this case, it's going to generate\n
we will see how we can use this layout file\n
So basically, this inner class is responsible\n
to have access to elements inside your view\n
this inner class. For example, in here, I\n
we had a TextView in our list item, the ID\n
down in here inside the constructor, let's\n
But because we are not inside an activity,\n
like this. Instead, what we can do is that\n
passed to this constructor. For example, I\n
can see that we have this method in here.\n
you can simply say find view by ID. But in\n
we can use this view or we can say item view\n
address our TextView I can see our.id dot\n
elements inside your layer file, you can add\n
later on in few minutes. But for now we are\n
minimize this. And now we can extend the RecyclerView\n
class. The way to do that is like this, we\n
we can see that we have this option. Also\n
view holder. If you import this adapter inside\n
There are also multiple view holders Make\n
class this orb that may code that your project\n
recycler view, so make sure to don't confuse\n
adapter for list views as the data type of\n
view holder class is exactly like that. And\n
at the end is this view holder class, the\n
Okay, now that we have extended recycler view\n
to be specific we need to implement some methods.\n
can see, we have three mandatory methods on\n
this get item count method. let's implement\n
a constructor for this adapter class. Let's\n
by going to construct it we can create our\n
methods in here, I'm going to create a model\n
video, I'm going to show some contacts inside\n
a model for those contacts. So inside my project,\n
name it contact. For this contact, I'm going\n
say private string name. After that, Let's\n
going to define a new string, let's say private\n
to be useful. Basically, we are going to show\n
URLs. And after that, we need to create our\n
insert, we can do that. Let's also create\n
I'm going to use all of them. later on. If\n
Let's also create a two string method this\n
our contact model. Let's close this class.\n
going to show a list of different contacts.\n
different contacts to this adapter class.\n
I'm going to create an ArrayList or to a specific\n
say private ArrayList of contacts, let's name\n
very important to initialize your ArrayList\n
get a nullpointerexception. Also, because\n
we also need to create a setter method so\n
main activity, we can set the initial data\n
the get item count method, I'm going to press\n
menu, we can create a setter for our contacts\n
activity, we will pass our data we're using\n
important point in here. Imagine that you\n
of your contacts from a web server from internet,\n
from the internet may change during the time,\n
recycler view should be changed as well. If\n
contacts method in order to change the data\n
the data inside your recycler view, you need\n
method. That method is called notify data\n
the data set for our adapter in this case\n
the list of different contacts at any time,\n
data set has been changed. This way we can\n
that we have received or passed to this adapter\n
And let's start working on these three different\n
this get item count, you can guess its purpose,\n
items in your adapter. In this case, we know\n
contacts. so we can simply return the list\n
That's all we need to do inside this get item\n
the number of items inside your adapter. And\n
I think that's enough for this video. In the\n
working on these two methods. After that,\n
layouts in recycler view. And after that we\n
order to show different contact images in\n
Okay, let's continue our talk about creating\n
let's quickly have a review of what we have\n
the RecyclerView dependency in our Gradle\n
module app inside these dependencies, you\n
After that we have added this recycler view\n
this relative layout, we have this recycler\n
dot java file. We have initialized our recycler\n
the layout file for every item in our recycler\n
layout file called contacts list item in our\n
look It's a simple relative layout, which\n
change this. After creating the layout file\n
adapter class. We have done that by adding\n
of that class was contacts recycler view adapter\n
this inner class, we have named it view holder\n
have extended the recycler view dot view holder.\n
this constructor in here. As I said in the\n
responsible for holding the view items for\n
instantiate all of our UI elements from inside\n
this view holder class if you want. After\n
class in here, we have extended the recycler\n
type, we have passed our inner view holder\n
adapter, we needed to implement three mandatory\n
view holder and get item count methods. We\n
video. But before that, we also created a\n
in our package. This contact has a name, an\n
this video, we will see that how we are going\n
creating our model inside our adapter class,\n
contexts in which we have named that contacts.\n
list I said that we are going to get a nullpointerexception\n
later on when we create an instance of this\n
So for that we have created this empty constructor.\n
in order to pass the data into this adapter\n
we have used this set contacts method in which\n
activity. After passing the data to this adapter,\n
set has changed so that we can refresh the\n
the previous video, we have talked about this\n
to return the number of items in our adapter.\n
array list dot size. Okay, now it's time to\n
let's close all of the extra classes and files.
And let's start working on this onCreate view\n
type of this method is a view holder. It means\n
our view holder to place to instantiate our\n
here. In order to create our view holder class.\n
We can do that by saying view this one in\n
were inside an activity, we could have said\n
a class beside our activity, we can't use\n
we can say layout inflator with capital L\n
that this from method is waiting for our context.\n
method that this is a static method. In here\n
this view group in order to get the context.\n
and I will talk about it. You can see that\n
can say parent dot get context. As you can\n
and we are using this layout inflator to generate\n
is that to inflate a layout for some reason\n
can say dot from and inside that method we\n
layout with the help of this layout inflator\n
after this Fromme method, we can say that\n
we can generate our view object. In here,\n
all, we need to pass the address of our layout\n
I mean that contacts list item, that XML file\n
our dot layout dot, let's say contact list\n
group, in this case, its name is parent, once\n
that, we need to pass a Boolean. I will talk\n
Let's fast forward. So in this case, and now\n
about these two arguments in here, this view\n
view group is the parent of all of the layout\n
layout, linear layout, and also constraint\n
different views inside it. If you want to\n
to your main activity just for testing purposes.\n
name with relative layout. from the previous\n
documentation in Android, we can press down\n
name, we can have access to the relative layout\n
you can see that this relative layout is extending\n
parent of all of our layout files. But why\n
arguments inside our adapter class. Before\n
line of code. We have created this just to\n
in here inside this inflate method, we are\n
that Where do you want to attach your view\n
of our adapter object from inside our main\n
files, we have defined a relative layout,\n
layout. And this view object in here, our\n
attached to that relative layout inside our\n
this view group has the name of parent in\n
can see that the name of this Boolean is attached\n
I just said that I want to attach my view\n
here because if we pass through, it will be\n
group as the parent of our view object. And\n
We have this Boolean because we can also pass\n
about our parent, and about where our view\n
view group, we can simply pass now, you can\n
to route. So if you passed now, you're not\n
view is going to be attached to. But of course,\n
I'm going to pass parent. And for the Boolean\n
this line of code with the help of this layout,\n
object. Now it's the time to create our view\n
if you take a look at the constructor of this\n
this constructor in here is accepting a view.\n
an instance of this view holder class. So\n
the one that exists in our adapter class,\n
view, let's say view holder, let's name it\n
first review. After that, let's return our\n
method in here this oncreateview holder is\n
for every item in our recycler view. Later\n
view holder method as you can see in here,\n
of our UI elements. Let's see how we can do\n
which I believe is the most important method\n
going to use the properties of our view holder\n
file, we have only one TextView. So if I want\n
something like this, I can say holder dot\n
text. You can see that in here we are able\n
Inside our view holder class, we had such\n
If you remember from the Java session, I said\n
the parent class, you can have access to all\n
inner class. In this case, inside this adapter\n
even though it's private. Okay, but what do\n
can see, beside this folder, we also are getting\n
like the position that we have inside ListView\n
of the item in our recycler view. Once again,\n
data for example from our contacts ArrayList.\n
can say contacts, dot, let's say get. And\n
Also, during the time, I've seen that the\n
it was named it sometimes it was position\n
this integer is just the position of every\n
after getting the corresponding contacts,\n
to set the name of our contact to this TextView.\n
view that you can create. You can have all\n
layout file, and after that inside this unbind\n
onClick listeners for each one of you I elements.\n
time, our adapter class is ready, we have\n
view adapter class. Now that we have created\n
back to our main activity and pass some data\n
method, we have instantiated a recycler view.\n
of different contacts. For example, let's\n
name it contacts is equal to new ArrayList.\n
in here because we don't know anything about\n
application, these data are probably coming\n
add some data to our contacts ArrayList.
As you can see, I've added some contacts into\n
a name also an email. And beside that I've\n
is just one point in here. And that's regarding\n
the address of some image from the internet,\n
example, like this dot jpg, or dot png. Those\n
So make sure to select the images that have\n
because some students asked me before how\n
quickly show you one example. For example,\n
images. And by right clicking on the image,\n
in another tab, you can paste that address\n
good to go. Okay, after creating your contacts,\n
For that, I'm going to say contact recycler\n
to new contacts recycler view adapter. We\n
so you're good to go. After that, we can use\n
say adapter dot set contacts, and we can pass\n
instance, and setting the data, we can set\n
in here, I can say contacts recycler view\n
in a ListView. That would be the end of everything.\n
in recycler view, there is also one more step.\n
recycler view as well. Let's quickly set that\n
RecyclerView dot set layout manager. In here\n
pass a linear layout manager and we can pass\n
in which for its constructor, we need the\n
activity, we can safely pass this as the context.\n
view to a linear layout manager. We are saying\n
in a linear fashion. The other option that\n
a look at that. But in here, this linear layout\n
to change that, for example, if you want to\n
will do that in a minute after running our\n
is ready to test. We have created our recycler\n
also have created this dynamic list of contacts.\n
class. We have set the data inside this adapter\n
to a recycler view. We also have set a layout\n
the application. And let's see what does a\n
list of different contacts name are being\n
If I had more contacts, I could have scrolled\n
all of them. Right now they all can fit on\n
Let's quickly change this linear layer to\n
So in order to have a horizontal linear layout,\n
manager dot horizontal, this one in here.\n
order to have a linear layout manager. Beside\n
pass that I'm going to pass false. As you\n
layout. If you want to reverse the order of\n
through in here. But I don't see any reason\n
Let's run the application once again. And\n
looks like. You can see that this time right\n
screen. And that's because when we created\n
view, we have past match parent as the width\n
items, you can scroll the window horizontally,\n
So this is what this horizontal linear layout\nlooks like.
quickly see the other layout manager that\n
one. The name of the other layout manager\n
all of these. And inside this set layout manager\n
For the inputs of this constructor, we need\n
After that we need the number of columns.\n
two in here is going to divide our screen\n
specific to different columns. And it's going\n
But before I run my application, I'm going\n
the contacts list item that XML file, I'm\n
of my relative layout to let's say wrap content.\n
it to match parent. I'm going to change that\n
You can see that the screen has been divided\n
we can see the contacts name in two different\n
this grid layout manager. Okay, now let's\n
each one of these items in our recycler view.\n
items, they are not going to do anything.\n
need to do that inside our contacts recycler\n
It was in our Java folder inside our project\n
you remember, I said that this unbind view\n
in your adapter class. And inside this method,\n
element that you want. Also, if you remember\n
an ID for this whole relative layout. If you\n
TextView but I think it's better To define\n
layout, because as you can see, we have this\n
layout are not going to be clickable if we\n
because I'm going to define the onClick listener\n
class, when I've created this view holder\n
to reference the relative layout as well.\n
name it parent. We also need to instantiate\n
can say parent is equal to item view dot find\n
parent. After defining this relative layout,\n
unbind view holder method. So for example,\n
is the name of this relative layout, dot,\n
that we have this option. Let's pass our interface\n
going to show some toast message. Let's say\n
make text method on our toast, we needed a\n
to any kind of context. Once again, we will\n
activities in Android, both inside this adapter\n
So we have to pass it inside the constructor.\n
as the member variable above in here, let's\n
And after that, I'm going to receive that\n
Let's name it context. Inside the constructor,\n
Whatever now that I have changed this constructor,\n
see some red warning. When we have instantiated\n
once again, because this time we are inside\n
this way inside our adapter, now we have a\n
we can pass that as the context. For the text,\n
So I can say contacts the ArrayList that we\n
to use this position as the index.
Let's say that get me. Also, if you have noticed\n
this onClick method, because we are inside\n
added to the declaration of this integer.\n
say selected. Let's quickly run the application.\n
onclicklistener on our relative layout. Let's\n
social arona social romance. It seems like\n
I think that's a good point to stop the video\n
URL and how to show that in our recycler view.\n
little bit long. So I'm going to talk about\n
also talk about using a combination of recycler\n
two will generate a really beautiful look\n
next video. In the previous video, we have\n
I mean, we have created a skeleton of our\n
If you take a look at your contact list item\n
in your recycler view is just a simple text\n
around this and we are going to see how much\n
recycler views. The first thing that I'm going\n
of this simple TextView and its parent which\n
contacts in a card view. For that first of\n
into our project. In previous videos when\n
we have added the material design library.\n
view instead of using the material design\n
Android cards Let's see where we can find\n
for card view dependencies, you will end up\n
x in your search because if you search for\n
Let's quickly take a look at that. In here\n
you are using comm dot Android dot Support\n
in our project right now, if you remember,\n
added the Android x artifacts. If you want\n
your gradle file. Let's quickly do that. So\n
in this build that Gradle module app, in these\n
using Android x. If for some reason you're\n
this support libraries version. But because\n
not going to be helpful for us. So make sure\n
And the first link from the official Android\n
link. Then in here, you can see the dependencies,\n
add the dependency from Android x packages.\n
it into our project. So once again, inside\n
these dependencies, we are going to add our\n
And let's sync our project. Now that I've\n
I can use it in my layout files, for example,\n
instead of this relative layout, I'm going\n
from Android x packages. If you remember in\n
be helpful in here. The first one is card\n
some 3d shapes to our card. For example, if\n
FTP. The next one is called corner radius.\n
to save five dB, I will change these numbers\n
card view, instead of this TextView, I'm going\n
relative layout is that because I'm going\n
to use some of the attributes like layout\n
that. And those attributes are available inside\n
in here, I'm going to create a relative layout.\n
parent. And I think that's enough for our\n
I'm going to move this TextView. First of\n
let's say center horizontal and let's pass\n
of this text. That's a text style. And let's\n
create another text view and I'm going to\n
this TextView. Let's change the contact name\n
to txt email. Let's also move this to below\n
txt name. Let's also change the styling here.\n
add some margin top margin top, let's say\n
horizontal attributes. Okay after these two\n
for that I'm going to create an image view.\n
of this image view because I want to have\n
numbers manually because my images are coming\n
about their size. For example in here I'm\n
fine. For the height as well. Once again 150\n
Let's just say image. I'm going to move these\n
below. And let's pass the email. Let's add\n
I'm also going to center this image via horizontally.\n
pass through. Let's also add a placeholder,\n
one of our images in our package. I think\n
Okay, I think that's enough for our current\n
let's just have a quick look of what our current\n
this coronary radius. For example, let's say\n
that, let's increase this card elevation.\n
you're satisfied. I'm almost done with this\n
reformat my code so that when I publish this\n
that, I'm going to go to this code tab in\nhere.
And down in here, I'm going to select this\n
been rearranged. Okay, now that I have changed\n
changes inside our recycler view adapter file\n
our view holder class, we need to address\n
item dot XML file. First of all, we have deleted\n
that with the current view. So in here, instead\n
current view. And let's also add our email\n
with this txt name. Let's say txt email. And\n
constructor. So let's say txt email is equal\n
txt email. We also need to add some quotes\n
example, we are going to show the contacts\n
holder dot txt email, dot set text. Let's\n
I'm going to pass position, let's say dot\n
I'm going to run the application. And I'm\n
fine. So let's run the application. You can\n
how much we have improved our layout. But\n
For example, we need to add some margin between\n
a margin top for this txt name. Let's quickly\n
list item dot XML file, for this parent card\n
top or instead of margin top, I'm just going\n
Beside that, let's also add a margin for this\n
a seven dp. Let's also add a margin was thought\n
I'm going to say margin start this one in\n
the application once again. You can see that\n
two attributes that we have added for our\n
all, we have added this corner radius, you\n
with a shadow behind our card view is for\n
the reason that we are seeing two columns\n
that we have passed to our recycler view.\n
change that, for example inside our main activity.\n
we can pass a linear layout manager. So in\n
And let's pass our context. Before I run this\n
centered my recycler view. Let's switch to\n
our recycler view. Let's say center horizontal.\n
change the width attribute in here to wrap\n
Right now you can see that we have only three\n
recycler view that's we could do that. You\n
screen. Our recycler view is a scroller but\n
Let's click on this link. cart view. And you\n
to be perfect. Okay, now let's work on this\n
images. For that we have multiple options,\n
called glide. Let's add that into our project.\n
for glide dependency, the first link from\n
library. Let's see what does it look like.\n
First of all, we need to add these two into\n
in our gradle file. Let's open our project\n
that Gradle project spawn in these repositories,\n
quickly add them. I'm going to copy this one\n
repositories for all projects.
Beside that, we need to add these two dependencies\n
design module app, we need to add the dependencies.\n
let's also talk about the SQLite. So glide\n
by Google so you can safely use it in your\n
in which one of them is to load images from\n
see other functionalities as well. But if\n
documentation in here, let's click on this\n
this page if you want. But we will talk about\n
switch back to our project. And it seems like\n
Let's close these two Gradle files. Also,\n
And let's go to our contacts recycler view\n
unbind view holder method, I'm going to show\n
I'm going to use the glide inside this method.\n
show images with glide library, you can say\n
capital G. And after that, you need to pass\n
with for the context in here, I'm going to\n
the context via the constructor of this class.\n
one in here. Now that we have our context,\n
that, I'm going to say that this image is\n
bitmap. After that, we need to pass the source\n
pass the image URL for our contact image,\n
image URL for that I'm going to say contacts\n
position as the index. That's a dot get image\n
view that we want to show our image inside\n
going to address my image view, which I can\n
of all, we need to add this image inside this\n
this view holder class, first of all, I'm\n
it image. And let's also instantiate it inside\n
to item view dot find view by ID r.id dot\n
First of all, we need to pass our context.\n
to be a bitmap file. After that, we need to\n
load method. And after that, we need to specify\n
image inside that this is going to work fine.\n
do one more thing. We are going to load different\n
to add a permission into our manifest file\n
talked about requesting permission. Let's\n
project main inside the app folder, inside\n
manifest dot XML file, we can add our permission\n
I can open a tag and the tag is going to be\n
need to assess To find the kind of permission,\n
can see this Android permission that internet.\n
regarding these permissions, we will talk\n
permissions, you need to create a UI logic\n
to your application. But this internet permission\n
your manifest file, the Android system is\n
we need to do in order to request for an internet\n
permissions. Let's just run our application.\n
You can see that we are seeing different images\n
this application after adding the permission\n
able to see the images. And that's because\n
you change your manifest file, you need to\n
again. So if you're not seeing different images,\n
install it once again. After that, you should\n
others you can see that the images are loading\n
can see that our recycler view our cart views\n
The combination of these three we'll create\n
to show a list of different items. And probably\n
of the functionalities of recycler view, you\n
our list item layout files however we want.\n
just to see our recycler view better. I'm\n
once again to a grid layout manager. And after\n
it back to grid layout manager and let's run\n
our RecyclerView seems perfect. Okay, I think\n
video, we are going to see how we can use\n
and external font that we don't have in Android\n
In this video, we are going to talk about\n
fonts to our TextView. Whether that font exists\n
add it externally. I believe this will be\n
we can add an external font into our project.\n
file and give an ID to this TextView. Let's\n
external font in your Resources folder, you\n
click on your resource folder. By selecting\n
that directory. We have done this when we\n
you just need to define the type of your resource,\n
all you need to do. Now you can see that you\n
external fonts into this folder. For example,\n
this font into my project, I need to do some\n
the name of this one. In order to add this\n
some rules. For example, you need to change\n
also you shouldn't use hyphens, instead of\n
I'm going to change the name a little bit.\n
you have changed the name, you can simply\n
you can paste it. The name is fine. Let's\n
have this Amsterdam, the TTF. If your font\n
clicking on your font. Okay, now that we have\n
it on our text view. Let's switch to our TextView\n
called font family. This one in here. And\n
font slash amster. No. Let's use to split\n
in the preview. You can see that right now\n
this will be changed when we run our application.\n
we can successfully change the font up artix\n
has been applied on our text the beside using\n
use some fonts called Google fonts. Let's\n
I'm going to switch to design view and search\n
that, we need to click on this text view.\n
that we have this attribute, and beside our\n
you have this drop down icon. If you click\n
some fonts that we can use. But besides all\n
And when we click on that, you can see that\n
Also, you can see the source in here it says\n
and you can safely use them in your applications.\n
somewhere. Okay, let's see what do we have\n
this calligraphy T or something like that,\n
we have two options, create downloadable font\n
means that you don't want to add the font\n
font every time that a user uses your application.\n
this option in here might not be that useful.\n
option which will add the font to my project.\n
apk file. Also, then in here, you can see\n
than one preview. And you can select between\n
regular. Also down in here, you can see the\n
your application. For the simple application.\n
going to be a commercial application. Okay,\n
OK, you can see that this calligraphy font\n
this will have a preview. So if I click on\n
Now if I run my application, I should see\n
You can see that the font has been applied\n
different styles for example, regular or normal,\n
see a font that has those styles. And let's\n
views. So once again, I'm going to click on\n
to click on this more fonts. The font that\n
two. If you click on that, you can see that\n
I'm going to add them one by one into my project.\n
to underline regular. And also I'm going to\n
a downloadable font. Let's press OK. And let's\n
You can see that now we have four different\n
on our text views, we can do the same as we\n
one font. For example, inside our text view.\n
the fonts manually by specifying the name\n
to the Android. For example, we can add a\n
size which can be it's fairly bold or normal.\n
if I change this lobster to Bold Italic to\n
that. If I run my application, I'm going to\n
Let's quickly run that. You can see that we\n
accurate because we have added the style manually.\n
to regular font. And if we want to use a specifically\n
font family for that. Let's quickly see how\n
resource folder, I can Right click, and by\n
a new font family. For the file name, I'm\n
case is lobster two. Let's create that. Inside\n
fonts, we need three attributes in here. First\n
For the first one, I'm going to pass the lobster\n
pass a style for this font, let's say font\n
styles Italia, and normal. In here, I'm going\n
bolder style, you need to pass that as a font\n
that we have this font fate attribute in which\n
fonts, these weights should be 400, I will\n
font weight that you need. But for now, let's\n
font. After that, I'm going to create three\n
the other three fonts, let's say font. Once\n
let's say lobster to retallick. For this style,\n
again, because this is not a bold font, we\n
Let's quickly add two more fonts for the bold\n
font I first normal as the font style. But\n
only difference between a bold and a regular\n
view half past 400 both for the bold ones\n
quickly see where we can find the proper font\n
developer, you can see this font weight from\n
And in here inside this companion properties,\n
fonts. For example, we have past 400 for the\n
For the bold ones, we also passed 700 I believe\n
If you pass for example 500. When the fonts\n
between these 407 100. So if you want you\n
back to Android Studio. Now that we have created\n
main dot XML file. But before that, you can\n
If you hover over one of them, it says that\n
26 and higher. So if your application is running\n
won't be applied. I've seen that some people\n
For example, you can see up in here, of course,\n
ALT plus enter, you can see that this new\n
talk about name spacing here. But basically\n
programming languages, you also have namespaces.\n
attribute is coming from. So some people are\n
you use this app namespace instead of Android,\n
levels as well. But honestly, I didn't see\n
one back to Android. And in my activity, main\n
So in here instead of passing lobster to regular\n
that we just created. And now this way we\n
system. So even though we are using this lobster\n
here, at the end, our font is going to be\n
our application and let's see if we can see\n
the bold font. Once again the difference in\n
this lobster to bold. But when we have passed\n
to bold, only the Android Studio increase\n
between different font styles. When the designer\n
a font family is much more accurate. Okay,\n
to show you how you can apply different fonts\n
in the design view, I'm going to add a button.\n
to change the font of this TextView. Let's\n
to let's say btn, change font. And also let's\n
text. I'm just going to say change in our\n
After that, let's set an onclicklistener.\n
new onclicklistener. Before this onClick listener,\n
that, I'm going to change the type face of\n
So above in here, let's say typeface, you\n
graphics package. Let's name it typeface is\n
to our font in our Resources folder. If I\n
that gets resources that get font. And if\n
say R dot font dot, let's say Amsterdam, you\n
in here. And the warning says that this method\n
You can overcome this problem by using resource\n
Let's quickly see that. So in here, I can\n
all, we need the context which I'm going to\n
font, let's say our dot font dot Amsterdam.\n
resource compat, which is a good option for\n
your typeface inside the onClick method, you\n
And you can pass your typeface. As simple\n
to let's run the application. And let's see\n
font is lobster too. If we click on this button,\n
it seems to be perfect. Okay, I think that's\n
for this section of the course. There are\n
when you're designing your layout files. For\n
have bottom navigation views, you have animations\n
I'm not going to talk about them in this section\n
concepts that we don't know anything about\n
a lot more tools for designing our layout\n
to have a quick challenge for this section\n
learned everything that we have talked so\n
at the end of the previous video, In this\n
The purpose of this challenge is to make sure\n
talked so far. And here is our challenge,\n
You can think of this layout file as a simple\n
the user's name, email, password, gender,\n
image view in here plus this button which\n
navigates to the user's gallery, or maybe\n
we don't know anything about that yet, this\n
purposes, these are not going to do anything.\n
after clicking on this image button. Beside\n
down below that you can see this checkbox\n
the register, we are going to show a snack\n
successfully. But if for example, the user\n
going to show a warning. Beside that we are\n
our license agreement. Okay, this is our challenge.\n
I'm sure that you can do it by yourself. But\n
lot of things that we have learned in In this\n
with a lot of UI elements beside that as you\n
Also, we are going to show a snack bars. And\n
initialize and work with our UI elements in\n
layout for that you want in order to design\n
in constraint layout. But if you want, you\n
Okay, pause the video in here and go solve\n
back to see my solution as well. Okay
I hope you solve the challenge, let's quickly\n
by creating a new project. For the name of\n
I'm going to save it API level 19. In this\n
let's start working on our layout file. But\n
extra files and panes. As I said, I'm going\n
want, you can work with linear layout or relative\n
TextView. And let's drag all of our items.\n
image profile. For the sample data, I'm going\n
a button. Beside that we are going to need\n
in a minute. But before that, let's quickly\n
edit texts in here, the first two are going\n
going to be password. The first two are for\n
passwords in here. The difference between\n
is that when you type something inside the\n
itself, but you will see some dots. Also beside\n
After that we need a radio group. Let's quickly\n
radio buttons. Also, I'm not sure that if\n
in your radio group in the design view. Previously,\n
a radio group in the TextView. But here is\n
you can use these components three, for example,\n
radio group. Let's add two more. Let's also\n
group. Let's search for the orientation in\n
to change it to horizontal. Beside that we\n
we need a spinner in here for selecting one\n
Let's quickly change the viets of this spinner\n
is not match parent in here, it's just some\n
Also I think it's better to put it above in\n
everything. If you remember we had the button.\n
our button register. Beside that we need a\n
And also we needed a checkbox. Let's search\n
value of this checkbox to true let's search\n
Also, I'm going to change the checked value\n
let's quickly change the idea of our UI elements\n
I'm going to fast forward the process of giving\n
UI element and you can change the attributes\n
Just a quick review, let's quickly see the\n
going to use them in our Java file. This one\n
edit text name edit text email, edit text\n
this morning here is our agenda for our radio\n
be male or be female and or the other. This\n
is called a screener country and this button\n
called a txt agreement. And this checkbox\n
to need four more text views. If you remember\n
button, we are going to make sure that we\n
if for some reason the user don't enter anything\n
warnings and we are going to use text views\n
more text views. I'm going to add Warning\n
Let's quickly give some ID to these. For example,\n
the rest of them. This one is txt one email.\n
txt var is repeat. Okay, now that we have\n
quickly change the initial values. For example,\n
anything, but for this edit text, I'm going\n
hint. Let's search for the hint. That's just\n
options, which can be annoying by pressing\n
rid of that suggestion, let's do the same\n
this TextView, I'm going to change its value\n
let's change the first one to make the next\n
name either this TextView in here, let's change\n
buttons text to peak image. And this font\n
Beside that, we need to change the value of\n
later on when we created our constraints.\n
Also, I'm going to change the color of these\n
that. Let's search for color. And let's change\n
be fine. Now let's start constraining our\n
I'm going to constrain it to the left of my\n
of course, I need some merging. I will add\n
this image view to the left of my button,\n
of my screen. Beside that I'm going to constrain\n
Similar thing for the top of my image view.\n
view. For example, margin top, let's say 32,\n
But as you can see, when I move this image\n
I'm going to delete this right constraint.\n
this button to the right of my image view.\n
right of our screen. And now we can move it.\n
First of all, I'm going to add a horizontal\n
and let's go to this helpers. And let's add\n
to somewhere about here. I think it's fine.\n
Let's quickly add that helpers add vertical\n
Now let's constraint our edit texts. For example,\n
this TextView to this guideline as well. Also,\n
of this edit text to the bottom of this TextView.\n
each other. What you can do is that by pressing\n
them. And by right clicking, you can use this\n
let's say Edit Text name, let's say top to\n
see that now we have a constraint. Beside\n
top of this TextView to our horizontal guideline.\n
And let's right click constraint txt warning\n
I'm going to remove the margin here you can\n
that to zero, I believe is fine. Let's do\n
text views. For these three remaining text\n
top edit text but I'm also going to add a\n
email top to the bottom of our edit text name.\n
I'm going to save it 16 Okay, let's do the\n
We can see that everything looks better. Now.\n
you can always go to this icon in here and\n
you can work with blueprint view, which you\n
Let's quickly see that you can work with this\n
save it to design view. Okay, let's add a\n
all, I'm going to construct it to the top\n
top to, let's say, bottom of our edit text,\n
24 would be fine, it seems too much, let's\n
of our screen, let's add a margin in here\n
the radio group from this component tree.\n
it to this guideline. Also, I'm going to add\n
to the bottom of this gender TextView. Once\n
let's say constraint. It seems like I didn't\n
this component three if you want. Let's select\n
let's say radio group gender, top to bottom\n
let's also add a margin, I think 16 would\n
do the same thing. For the left margin, let's\n
constraint. txt country talk to the bottom\n
months again, for the spinner, I'm going to\n
And also its bottom and top to the bottom\n
course, we need a margin left. Let's quickly\n
to constraint it to the three edges of my\n
add 32. For example, I think that's fine.\n
guideline in here. Let's quickly add that\n
move this guideline, let's move it to somewhere\n
to this one in here. For the top, I'm going\n
Let's also constraint this checkbox. I'm also\n
to the bottom of our TextView. Let's add another\n
a horizontal guideline. And let's move it\n
add a constraint from the bottom of this checkbox\n
like we don't have a proper constraint in\n
constraint, we can delete the constraint by\n
to delete key. Let's also add a constraint\n
horizontal guideline. Also, I'm going to move\n
Now, let's also change the text of this TextView.\n
four warning text to gone. First of all, let's\n
see that as soon as I typed the TextView in\n
other layout files. And also it doesn't fit\n
can click on this to arrow in here. And you\n
what we also need a margin. Let's quickly\n
that seems with it. Also, I think it's better\n
Let's click on that. And let's move it above.\n
the visibility of this for one new text views\n
let's change it to gone. Similarly for the\n
that, you can see that we have two small margins,\n
say eight in here. Similarly for the next\n
that's about the size of our layout file.\n
Let's quickly add them in our strings values\n
strings. I'm going to add an array string
let's say array. Let's name it countries.\n
main dot XML file, we can pass this as the\n
and let's address our country's array. Okay,\n
image view, we also need a source. Let's search\n
see source in here, let's switch to text view\n
Let's say source. And let's pass this mid\n
testing the application, let's quickly add\n
to go to material.io. Let's go to this Developer\n
Android in the documentation getting started.\n
add that in our project Gradle script build\n
the dependencies. Let's add that we also need\n
see in the warning, the latest version is\n
let's go to our styles and change the theme\n
theme in here. And I'm going to use team dot\n
We have used these previously in previous\n
main file, you can see that the state of our\n
I'm going to run the application on pixel\n
relatively good job, we just need to increase\n
to change the width and height of this image\n
say 130 dP, I think that would be fine. Let's\n
you can also decrease the size of this TextView\n
design might be different than mine. It's\n
a designer, but we just wanted to practice\n
that's enough for this video. In the next\n
file and we are going to work on the logic\n
In the previous video, we have created this\n
video, we are going to work on the Java file\n
that, let's switch to our main activity dot\n
First of all in here, I'm going to initialize\n
quickly add a lock, I believe it will be useful,\n
text, I'm going to fast forward the process\n
you can see that it's very boring. I'm also\n
in here, let's say private constraint layout.\n
on, we will use this constraint layout to\n
to my constraint layout. So for that, let's\n
our split view, in the parent constraint layout,\n
I'm going to say parent. Okay, now let's initialize\n
that inside another method. Let's name that\n
let's create that method down in here, private\n
a look. Let's get started. Let's minimize\n
again, I'm going to fast forward the process\n
I have a typo in here. But I have set an ID\n
that in our layout file. If I click on this\n
of sorry for that, I also need to change it\n
all of our views, I'm going to set an onclicklistener.\n
about this one in here. So after this method,\n
Let's just show a toast message. We haven't\n
a gallery, or for that matter to take a picture\n
just going to show this first message. After\n
btn finish or btn register. I believe I named\n
I'm going to do the job inside another method,\n
method down in here. Let's say private void\n
a look. Let's say start in here. First of\n
entered all of the data for that, I'm going\n
I will create that in a minute. But let's\n
we are going to continue. Let's quickly create\n
we are going to do inside this method. Private\n
let's say private, Boolean, validate data.\n
edit txt name dot get text.to string if it's\n
are going to show the warning text. So let's\n
visibility. Let's fast be Zeebo. I believe\n
after that we are going to return false it\n
we shouldn't continue our code. In this method\n
more if statement for the other three edit\n
string is equal to an empty string. txt warning\n
also going to return false in here as well.\n
false, we are going to change the text of\n
in the layout file, we didn't change the text\n
warning name, for example, dot txt, let's\n
other three cases. And after all of these\n
we reach to this point we are going to return\n
of the data. So inside this validate data\n
all of the blanks after that inside this init\n
we are going to check that if the user agrees\n
agreement check that is checked this option\n
to continue. But in the else case, we are\n
say you need to agree to the license agreement.\n
the user enters all of the data and also agree\n
show a snack bar. Let's do that in another\n
create that method down here. Private void\n
then in here inside this method, first of\n
of our warning texts, because those warnings\n
name that says visibility, let's say gone\n
other three remaining burning texts. After\n
remember, we can do something like this, we\n
we need to pass our constraint layout, which\n
need to text in here right now I'm going to\n
to say user registered. But later on, I will\n
the details of the newly registered user.\n
we need the constant for the length of our\n
length indefinite. Let's also define an action\n
that's an action. For the text, I'm just going\nto say dismissed.
Let's also create an onclicklistener, let's\n
I'm not going to do inside this onClick method.\n
finish creating our snack bar. But before\n
show. Let's run the application. And let's\n
First of all, let's click on the speak Image\n
can see that you have to be talked about.\n
a new user. Let's say Mesa, let's add an email.\n
passport. We also need to check that if these\n
do that after the testing of this phase of\n
I'm going to uncheck this alone. License Agreement\n
that you need to agree to the license agreement.\n
this time we should see this network user\n
working fine. If we press dismiss, the snack\n
this email in here. And let's see if we get\n
button, you can see that insert your email,\n
we enter an email in here, for example, may\n
button, we should see that the email warning\n
the application. First of all, I'm going to\n
I'm also going to empty all of these for any\n
so that we can add a new user. Also, I'm going\n
details of our newly registered user. Let's\n
validate data method, I'm going to add another\n
this font dot get text to string. If that's\n
get text to string. If that's the case, or\n
not the case. First of all, we are going to\n
password repeat. And after that, we are going\n
password repeat dot set visibility, let's\n
the text I'm going to say txt warning, repeat\n
match. Up. After that I'm going to return\n
data successfully, let's go to this onClick\n
text. I'm going to say Edit Text email or\n
an empty string. Similarly for the other three\n
is that I'm going to change the text of this\n
that text above in here, inside this short\n
to get the user's data. For example, let's\n
dot get text.to string. Similarly, for the\n
equal to edit text email dot get text.to string,\n
country, let's say a string country is equal\n
string for getting the user's gender, I'm\n
that I'm going to create a string, let's say\n
After that, let's create a switch statement\n
get checked radio button ID. Let's say in\n
are going to change the value of this gender\n
Sorry about that. Let's also add a break in\n
say gender is equal to female. This default\n
purposes, if something goes wrong, I'm assigning\n
switch statement, we have all of the data\n
that we want to show inside the snack bar.\n
and let's create our text. First of all, I'm\n
or we got from the Edit Text name. After that,\n
go to the next line, let's say email, plus\n
also show the gender and country, let's say\n
n and also let's show the country. Now that\n
in our snack bar. So this time, instead of\n
Let's run the application once again. And\n
successfully. Let's test the different cases.\n
warning if we enter different passwords in\n
I'm going to enter 123456 but in the reenter\n
If we click on this register button, we should\n
Okay, let's add six in here. Now they do match,\n
Switzerland. And also let's change the gender\n
reduce there any user. In here you can see\n
have created. But we are not seeing all of\n
If you want to change the maximum line attribute\n
of all, you need to get the instance of your\n
text view of your snack bar. And after that,\n
text view. This way, you can override the\n
your snack bar. But that seems like a lot\n
here. We will do that later on in the course\n
in here, if you want to make sure that you\n
you can simply log it. For example, in here,\n
let's say a snack bar text. Let's pass our\n
and test this, I'm going to click on this\n
the logic so that we clear all of our edit\n
are now ready to register a new user. Let's\n
test this snack text. For that I'm going to\n
here. And let's click on this register. You\n
may be some@gmail.com gender male country,\n
text successfully. Okay, I think that's enough\n
the challenge. In the next section of the\n
four of our applications. Now we know about\n
in the next section of the course we are going\n
our first real world application. Beside practicing\n
are also going to learn a lot of new stuff\n
of the course. And as always see you in the\n
having fun. Before we start creating our sample\n
there is an extended version of this course\n
course you will have lifetime access to more\n
questions directly from me and I will come\n
to all of the source codes that I wrote in\n
all of the new videos that I upload, just\n
the course. And don't forget to use Free Code\n
If you want to get serious in Android app\n
almost a necessity. Okay, everyone, I just\n
version of this course that you can take without\n
application. Have fun learning.
Hello, everyone, and welcome back. In this\n
the first application of the for real world\n
to say that in creating this application beside\n
so far, we are also going to learn a lot of\n
we create the application. Okay, now let's\n
to create an application that will help the\n
application, we are going to show a list of\n
can see the details of that book. later on.\n
to different lists, for example, at least\n
this book, or maybe a wish list or also a\n
on in the course. In the process of creating\n
all of our knowledge about user interface\n
learn about a lot of new concepts. After watching\n
the application that we create together and\n
So I highly suggest that you watch this section\n
more talking, let's create our project and\n
to start with empty activity as before. Let's\n
library. For the other fields in here, I'm\n
name, once again, I'm going to put my website's\n
name, which is my library to save location\n
save with API level 19. For the minimum SDK,\n
so I'm not going to check this option in here.\n
working on our layout file. Before everything,\n
into my project, because we are going to need\n
go to this Developer tab. Let's select Android\n
Let's copy this line of code. We have done\n
anything here in our Gradle scripts, build\n
Let's add that. And also the latest version\n
And let's sync our project. It seems like\n
First of all, let's change the style of our\n
of this app compat theme, I'm going to use\n
Let's close this. And let's switch to our\n
is going to have multiple pages later on,\n
or to be specific multiple activities. But\n
or the first activity of our application.\n
I'm going to have a text view for the name\n
to add a few buttons. One for the list of\n
of books by clicking on this button. I'm going\n
them. Let's also add an image view above in\n
with one of our avatars. And also I'm going\n
Let's give some ideas to our elements. For\n
it's going to be our logo. For the TextView\n
that we need an ID for this one. This button\n
our books. So let's say btn all books. Also,\n
see all books. Beside that I don't like that\n
can change that you need to search for all\n
Let's change it to false. Now you can see\n
second button, I'm going to change its ID\n
is going to show the list of the books that\n
currently reading. And let's change the text\n
let's change the text all caps value to false\n
change its ID to btn already read because\n
that the user already read. So let's say btn\n
read books. Once again, let's change the text\n
button, I'm going to change its ID to btn\n
because this button is going to show the list\n
list. Basically, this is the wish list. Let's\n
list. Let's change the all caps attributes.\n
to change its ID to btn favorite books, let's\n
to say see your favorites. Once again, let's\n
last button, I'm going to change its ID to\n
we are going to show a dialog in which we\n
let's say within about, and let's change its\n
to change its all caps attributes, because\n
an ID to this text view as well. Let's see.\n
to developed by mesa@miko.org. I'm also going\n
Let's search for text style. Let's change\n
the text of the first text view to the name\n
my library in here. Later on, we will change\n
add our constraints. Also, you can see that\n
feel free to use the relative layout or linear\n
layout. So I'm using constraint layout, let's\n
top of maybe 70 dP for this image view. But\n
because right now I cannot see that. Okay,\n
would be better. Now let's concentrate our\n
And also to the both side of our screen. We\n
50 dP will be fine. It seems too much, let's\n
buttons. For this one, I'm going to constraint\n
to both sides of my screen, I need the margin\n
the second one, I'm going to fast forward\n
if the items are too close to each other as\n
by right clicking we can use this right click\n
to bottom between all books. Let's add a margin\n
I think 16 would be fine. It seems too much.\n
For this last TextView in here, first of all\n
my screen. And also beside that I'm going\n
screen so that it would be centered. Also,\n
that seems better. For this image view, I'm\n
going to show the actual image. I have prepared\n
that I'm going to copy this image. Let's add\n
right click and paste I think the name is\n
For this image view, if you click on that,\n
this tools source compat and instead of that,\n
that we just added into our project. It seems\n
manually. Let's see 150 dP I think that's\n
seems a little bit better. For this mind library.\n
font family. Let's search for that in the\n
arrow more fonts. Let's search for a good\n
and you can use them in your projects free\n
let's add font to our project. And let's press\n
Let's also increase the size a little bit.\n
14 sp, let's say 18. So that seems better.\n
this layout file is the width of all of these\n
width right now you can see that these have\n
let's switch to a split view. Once again,\n
say 200 DPI, I think that would be fine. Yes.\n
you can see that it's much better now. Okay,\n
page of our application. Let's quickly initialize\n
double shift, you can search for main activity\n
Let's also initialize these buttons down below\n
do that inside another method, let's say you\n
by pressing ALT plus enter. Once again, I'm\n
By clicking on each one of these buttons beside\n
user to another activity. Up until this point,\n
was named main activity. But if we want, we\n
as well. We are going to talk about activities\n
an activity is really simple. There are a\n
will talk about them later on. But in here,\n
do something like this in your project inside\n
can right click on that by saying new activity.\n
The names of some of these activities may\n
we created our project. But basically in here,\n
select this gallery, in which you will get\n
Let's select empty activity. Once again. In\n
in here is that to use the keyword activity\n
and also other strange characters. For the\n
name it all books activity, because this is\n
to navigate the user when the user clicks\n
You can also see a checkbox in here it says\n
for your activities, it is possible to create\n
the XML file. We will talk about that in the\n
do need a layout file. So I'm going to leave\n
when I changed the name of my activity, also\n
name, you cannot use upper cases letter. And\n
cases. Beside that you cannot have spaces.\n
that if this activity is going to be a launcher\n
one of the activities can be launcher. Right\n
is this main activity. It means that when\n
is going to be shown. And for that I'm not\n
if you don't check this option in here, if\n
manifest file later, but more on that later\n
we are going to create this activity in our\n
once again, I'm going to use Java. Let's finish\n
happened in our project. So first of all,\n
you can see that we have this all books activity\n
folder, in the layout folder, we have this\n
has been created by the Android Studio. Beside\n
this Android manifest dot XML, you can see\n
new activity tag in our application tag, it\n
If you want to create your activities yourself\n
possible. Basically, you can create a java\n
file. And beside all of these, you need to\n
the manifest file. Also, you need to link\n
method. We will take a look at that in a minute.\n
the help of Android Studio. Okay, let's close\n
all books dot XML file, you can see that in\n
design for this activity. In this video, I'm\n
instead, I'm just going to change its background\n
once again, you can see that we have a constraint\n
constraint layout, I'm going to say background,\n
I think I'm going to pass this color accent.\n
that we have navigated the user from the main\n
now let's see how we can navigate the user.\n
all books activity dot XML file, and also\n
that we are going to navigate the user to\n
all books activity, so we need to create an\n
books that set onclicklistener. Let's pass\n
method is the place to write the logic to\n
an object that I have never used so far, and\n
that it's coming from Android dot contents\n
intent is equal to new intent. It's a simple\n
any other Java class. The constructor of this\n
need to pass a context in here, because we\n
by now we know that activities are context,\n
pass that main activity dot this. After that\n
you want to navigate the user to for example,\n
So this way, we are saying that this intent\n
to all books activity. After that when we\n
in here called start activity, you can see\n
And we can pass our intent safely. This start\n
view by ID which exists inside every activity.\n
that when we click on this button, the user\n
quickly test that. Right now you can see that\n
of all, we cannot see this license TextView\n
here. And also beside that this currently\n
We will increase the width of all of our buttons\n
see all books button, we can see that we are\n
if you press this back button. Once again\n
It seems to be working perfect. Let's quickly\n
finish off this video in our activity main\n
the margins. For example, this margin top,\n
margin top of this my library text. Let's\n
for all of my buttons. Instead of 200 dP,\n
the first one, let's say 230 dP. Let's run\n
if we have fixed the issues successfully.\n
enough for this video. Just before I finish\n
source code for this application@maker.org\n
you need I upload the source code at the end\n
see your feedback. Okay, in the next video,\n
for our books beside that we will create a\n
show a list of different books inside the\n
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.