Transcripts
1. Introduction: Hello, I am Humerus, and welcome to the complete Android and
Catlin app development two Z, Woodcomp Court. This is a course where you will go through beginner's level with simple projects and reach professional levels with more complex and
realistic projects. All you need is to be persistent and try
this course every day. On each day of the course, we go through a
learning cycle length, practice together,
recap together, and do a quiz together. If you don't like
quizzes, don't worry. Every quiz will be
answered the next day. But I insist that first
you try to do the quizzes and exercises by yourself
so you can learn more. During this cycle, I try to explain everything
in different ways, so you can learn by the
simplest way as possible. If you don't get something
in the very first video, you'll get it through entire course because we
will get back to everything and subject many times
to make sure that you understand all
of them very well. During this course, I will also teach you all the tips
and tricks that I have acquired over the years of my work experience as
an Android developer, fullstack developer
and project manager. You will pay attention to your Android
application both from the developer's point of view and from the management
point of view.
2. Day 1: Install JDK & Android Studio: Hello and welcome,
let's install. First, we should install JDK. We search for Java JDK. First link, Java downloads
in Oracle website, we click on this. We'll go to this address. Joa downloads. Joa downloads. Last version. You have previous version, as you can see, but you
want this last version. I don't have linux. I don't have Mac OS. So I don't need those. If you have these things, you can install them. But I have windows. So I click on windows. We have 64 version. So, which version
should I in at? Simply on this PC. I right click on empty space, for example, in here. You see, not on the fools. In here or here, on empty space. And I click on properties. First, you can see
I have windows ten, and then on system type
here. You can see. I have 64 bet operating system. So I have 64 bit. Let's come back to Oracle page. We have 64 bet in here as well. So we download this I right click on
this and save Link, and I save it on my desktop. On the desktop, I
already save this. What if you want,
you can press save. It takes a few minutes
to download it. After that, it's finished. I also download
the Android Sudo. For that, I search
Android Studio on Google. I see, we have this
developer that android.com, and we click on it. We're on Android Sudio Site, and simply click on
download. We have this page. We come down and
accept this agreement. Of course, after we read it, and then we can
download the app. We click on this and
this starts download. After it finished, we also have this Android Sudio
in installer file. This phone. I have the files that I
downloaded on my desktop. First, we install JDK. We should double click on it or right click on,
click in astall. Let's double click on it. This is the installer guide. We simply press next. This is the location that
ova install on your system, ova development it, as
you can see on the top. I accept this default location, press next, and it
starts to install. As you can see, Java
development kit successfully installed done. We write CMD because we
want to att command prompt. We write CMD. We have this command prompt. We can click on it
or simply press in. We have command prompt. We write Java space. Where en and press inter. What do we have? We have
Java version 22.0 0.1. So we successfully install
Java development kit this JDK, and we check to be
sure we did it right. So now we can be sure we
install JDK correctly. Let's go to the next level. I should mention, you should
first in install JDK, not Android Studio first, JDK, and then Android Studio, right click, run as
administrator or double clickon. Let's do this way.
Or double clicon. Okay. Next, what we
have here, checked. This is checked Android
virtual device. What is it? Virtual device for
testing your apps before exporting that
APCs for the real phones. You can test these
virtual devices inside your computer
without any phones, just with your computers. So how much space do we need? So we should have this much space on
our computer as well. Of course, in the future, we should add some other things. So be sure you have enough
space on your computer. Maybe at least 50 gigabyte. And I think it's better. You do this on your CD
dive, it's really easier. So you should put aside about 50 gigabyte
on your CDI for this. And I also recommend SSD
instead of hard drive. I think it's better to mention. Okay, press next. Where should I in a cL? As I say, I think it's better default locations
on the CD dive. It's easier because
without any thing to do, All the other things
can find each other. For example, and you easily
find JDK because that JDK in the default location or
the other things we in the future add find all
the other requirements. Anyway, longest story short, default locations is the
best and be sure you have about 50 gigabytes
at least on your SST, better than hard drive. Next. And what should we call
it on your start menu? And read you, of course, I don't change it
just in a stall. We've wait a few minutes,
so this is over. It's based on your
computer speed, maybe more than a few minutes. Since I have SSD, it took about a minute or less. Next, and start. I don't have come fi so
do not import setting. Press. I think it's
better to send usage statistics to Google to help to improve
Android Studio. Android Studio, find available
SDK components for us. As you can see, said welcome. Just press next. How do we want to set
up our Android studio? I think typical thing is better. What it's right? What's
the best things. Many of them they choose for us. Press next. I said, We do these things
for you. Is it okay? Said if you want to review or change any of your
installation setting, you can go and say,
I want custom. But if not, STCs and other things we
install them for you. Anyway, all of these
things is good. Just press next. Accept to all, I should accept
the license and finish. It starts downloading. Well, our installation completed these components are downloaded and
installed successfully. So now we can press finish
this finish button. Now we have Android Studio. And Studio welcome page. In this page, we can
create new project, open project, and
the other things. We have this more actions. Press SDK Manager. As we can see, we
installed STCs and we have this appearance and behavior on the top.
We click on it. We have this new UI. We checked the Andrew studio checked enable New
UI by default. We don't change it because
I think new UI is better. It's really better and
also in appearance. Our tm is dark. We have other things. You see light. Light with light header, Dracula, and high contrast. I think dark is good. It's good. I use dark most of the time. So no changes in here, but I just want you to see, we have this appearance, we have this new eye, and it's good by default. But if you want, you can change this to
light or any other thing. I prefer this one because
it's better for my eyes at can see we have this
virtual device manager. And we say allow access, any public or private network. We have this virtual
invoice in here. If we want to create new
virtual voice, as we can see, we have already one because we say and read the studio do
all of these things for us. But if we want to
create new one, we click on this plus button, this this Plus button, create virtual voice,
we click on it. On the left, we
have phone tablet, desktop TV, and even
OS like watches. We can pick one of these
and then press next, or even we can create
new hardware profile and have a custom hardware profile that doesn't exist
on those things. And we cancel. And when we find which one of
these things we want, we press next, Anyway, I just cancel it. And this is virtual device. Now, it's time for
our first project. I should just say
in the next video that recorded a few
months earlier, I show you how to
create new projects. But for now, since I saw Andre
the Sudio from beginning, Why did I do that? Because Andrew D Sudo in installation changed
a little bit, and I just want to show you
the latest in installation, how the latest version of
Andrew D Cdio, installs. Because of that, I
recapture this video open. In the next project, you can see the new project, but since as I say, it's a few months anyway. I just want to show you
when you press okay. And, you ask, Do you
trust this project? Do you trust this source
that you are opening? I just want to show you this. We can press this trust or
we can preview in safe mode. You can choose
whatever you want. Since it is my own project, I created myself
with you guys in the few days in the future. Lessons. I just
press trust project, and I can check. I trust the project
in this location. Don't you need ask
me these things? I trust this location. And I press trust because
it's my own project. And that's it. Thank you. And in the next video, we create new project together.
3. Day 1: Create First Application: Okay, we can open Android
Studio by double click on it. Now we want to
create new project. Our first project, we click
on this button, new project. We can see a few
templates in here. We can choose any of them. These templates are some small applications
with basic codes. For example, we have basic views activity
with this plus button. And also we have other things like navigation activity or button navigation
view activities. All of them have activities
and simple codes on them. If it's so many different
templates to you, don't worry, we make sure. So in this course, you can create most of these activities and templates
yourself an activity. As you can see below each of
these you can word activity. Activity is simply
call as a page, but it's not exactly
look like a page. We can be more specific
later on the course, but for now don't consider
activity as in a pages. For now, we start
with empty activity. We click next or
double click on it. You can press previous to go back to previous
page like this. When you choose empty activity, you can press next or
double click on it. Okay? You have name. This name that will be shown in the Android launch
for this application. What do you want
to call your app? Just remember, when you
install it on any phone, you can see this name, this name as the name of
your app on that phone. This name must show
what is your app. So I call my
application capital Y, capital H, and I say hi. Now, package name. What is package name? I think in many ways
to explain this, but the simplest way I
can explain it to you, the simplest way, imagine each house in your town
has a unique postal code. Two house with same
postal code can be found. Why? Because if we found two houses with
the same postal code, how can the post office make
a difference between them? The post office can
decide that this parcel belongs to one of them and the other belongs
to the other one. Anyway. Long story short,
each house with each postbox has
unique postal code. Never two houses have
the same postal code. This is long, but I think
I can make my point, and I hope you understand
what I'm saying. Package name is the same
thing as that postal code. It shouldn't be duplicate. Okay, Andrew, the studio, add my name application name at the end of the package name. But it has other parts
that separated with dots. For example, I can put my
domain name in here, 7204. Okay, We see this
error at the bottom. A digit cannot be the first character in
a package statement. What should we do?
This is my site. Since this is my website, I want to this be at the
first of my package name. I have.com I first
write the com, then my site is seven x 24. This is extra 7204. And my application is say hi. This package name is
unique because it starts with my domain name and
ends with my app name. Say hi. In case of my problem that your domain name
starts with a number, how should we fix? Because it happens
from time to time. You might have the same problem. Well, let's write under
line before seven. You see the character under line cannot be the first character
in a package segment. So I write site, my package name is com
site 7204 layer, say hi. It is unique because
no one else has a site with this name at
the end of that site. Because I want to
make a difference between my apps I write, say hi. I can understand this
is the application, it's the say hi application. Since this course starts
from basic levels, I will try to explain everything
as simple as possible. It will be a bit time consuming, but you will learn all
basic concepts very well. Anyway, as I say,
this is unique. And later on when you publish
your app on the play store, Google and all Android devices, know your application
with this package name. Some of Android tutorials
might say to you, if you don't have a website, say for example, write
example in here. Never do that. You can
use your own name. Your first name, it's okay. You can use your company name, you can use anything. But please never write
example in here. It's not right. For example, if I
don't have any, I write not my last name, but never example, Okay? Enough of package name. Let's see, safe
location, this is there. Your project will be saved
on your hard drive or state when you want this
project to be accessed again, you should use that place, name it right by default on the folder Android
Studio project. The Android Studio create
a project with the name, Say I changed the location. Okay. Let's press this button. This is the folder
that Andrew Studio, by default, selected for me. I changed it to Desktop. Can you see this small arrow? I press this so I can
see the other folders. I folder name, Projects. I click on this,
now I can save it. On my Projects folder
on my desktop. If I press the arrow
beside the projects, you can't see any other
folder because it's empty. You can see this is empty, okay? But it's better to
have an folder inside that project folder so I can find my project
between other projects. Okay. What is the spot? I have home directory, I have desktop directory, I have new directory. I want to create a new folder. Now Android Studio asked me what is the name of this
new folder name? I say zero under line, say capital, say hi. This is my foll. Now I can press okay. Or press in Android Studio, create A with the
name, say hi for. You can see it. This is the F that Android
Studio creates for me. I press okay. And you can see the
address on the top. Okay, This is my address. All of my sources say in
here now, minimum SDK. What is it? It's the lowest Android version that can run your application. Your application can't be
installed on the lower version. For example, if you
had your Android PK, you can't install it on Android six because minimum
SDK is Android seven. So you have to use minimum Android seven
to install that app. You can read, your
app will run on approximately 96.1 of devices. It means 96.1% of all Android devices
that recognized by Google Play Store have
Android seven and above. About 2% 0.9 of them are
Android six and below. If you change it, for example, let's
say Android eight. Now your app will run on
approximately 93.4% of devices. For now, Android seven is okay. We can have a
version of Android, but they are outdated
and I don't want that. Maybe you use some new
features of Android doesn't exist in a Android
versions like Android seven. And because of that, maybe you want Android eight
on Android Noi. But be careful, if
you, for example, use Android Noi, about 14% of devices
can't install your app. Anyway enough of this. We chose that Android seven. Okay. Build
configuration language. We have three options, but we continue with
recommended Catlin. Maybe on the course, we look at the other
options as well, but we stick to the
recommended language. If you have older version
of Android, for example, a few years ago in this place, you can also choose
Java for your app. But as you see, you don't have Java. You only have cutline
and groovy anyway. I leave it with recommended. Okay. Everything is good. We discuss all of these
and explain them. Let's press Finish. It takes about ten
to 20 seconds. So my project Create, and as you see, my Radial is going to download some files and some
packages for my project. Okay, it's finished. It takes about one
minutes for me. We'll continue the rest of this project in the next video.
4. Day 1: Checking The First Project: Okay, we came until this far and we just start
our new project. Our project doesn't have
activity underline. Mame if you are a
little familiar with, and you might wonder
there are layout files. You look for them in
the project folder, see the files, and
you can't find it. It's okay. I'll show you
what happened first. Let us see what do we have here. We have our follo,
our package name, and under the main activity
dot for Catlin file, the file extension is kt. Okay. Inside that file, we have a few code. Let me quickly see this. And then we will look
for the XML files. We have package name. This is the package name
that we defined when we were creating the
project for the first time. After that, we have this import. We have this arrow. If you open it, we have a
few imported libraries. For the first time when you create a project
in Android Studio, it needs a few packages
and files to download. Depending on your
Internet connection, it may take one to 10 minutes to download all necessary files. Just be patient anyway, You don't need to worry
about this part right now. We will cover all these
in future videos. Let's take a look
at the main parts. Here we have the main activity
as with a function called and create that runs every time you open your
app on the phone. In this function, another
function greeting is called to which a
string value is passed. For example, user. You can change it to
anything you want. In here we have this function
as well, name greeting, and it takes a string inside it, we create a text for that
text that we create. We set an attribute, attribute text with
the value, say high. Do you remember the name? Say High. Whatever this name is. The say high 999. I wrote it, this 999 after
it and I change this text. Don't worry about these
commands for now. We'll cover them all in the future On my app
with this button on the virtual device that I added to Android Studio
in the previous videos. After some time, my
app will open in virtual device as you can
see. Okay, I'm waiting. Okay, it's ready. I can see in my visual
voice that is pixel L P 34. I can see this, this is
my pixel Cel API 34. I have a few other buttons, I cover them later. If I zoom it, you
can see say high 999 as you see inside the text, because I create
this text and inside that I give it a text with
the value of say, high name. The name is 999. I have this. Let me this. Okay. And zoom a little bit. If you make an APK file off your app and install it
on a real phone device, you will see the exact same
output as you see here. Like this, it means whatever you see on
the virtual device, it's a preview of
your actual device. You all users phones, you can test it in here first. Okay. Now let's try to find the XML files where
our layout should be. As you remember, we create our new project
from temperate. You can choose file, new new project to
create new project, to create this empty
activity project. But something you
might not know, this logo is for composed, the project that we made. Some experienced programmers
do this mistake, as I see in the past few months, some of my own programmers
do the exact same mistake. Why? Because it's on the top and it seems
healthy activity. But it's composed.
What is composed? Compose is a new way to design
layout for Android apps. You create objects and items on each application page
using Catlin language. Compose is good for large
apps with many pages. And as the very first part of this course is
in beginner level, we will continue
with Mal layouts, but we come back to compose in future why I chose this format. In the last video, I wanted to show that you might do the same thing
and get confused. Even some of the
experienced developers I work with had done
the same thing. Then this new version
of Android Studio was released and didn't know
how to fix the problem. During this course, I may do the same by making
deliberate mistakes, so you can learn from them. If you want to create an
application with X ML layout, select the empty use activity. Okay, Press next. Let's name the
application I write, say high with main XML. I want to say that this
app is using XML layout. Of course, it's not a good name. You shouldn't write like this. You should write the name, Whatever your app actually do, user can find it with this name. Anyway, package name. I leave it because it's just
a test language minimum SDK. I cover all of these. I don't repeat them. Finish. Okay, now I
create my first project, but this time with XM layout. We will continue
with this project and start coding
in the next video.
5. Day 1: Completing The First Project (Part 1): Okay, I just reopen my
project in Android Studio. I see this tip of the day. You can check this
tip of the day. Don't show these
tips on startup, but I don't check this. I never check this. Why?
Because these are useful tips. For example, let's
read this tip. Convert Java classes to Colin. You can easily convert
any Java class to with the same semantic. To do that, select code. Convert Java file to Colin
file from the main menu. Anyway, we will cover
this in the future. Okay, back to our project. We have two foil, main activity and activity XML
inside each of them. As you see, there are
some codes as well. Inside the there's code. Of course you can see
how does it look like, but they both have some codes. You have these codes in both of these files because
you use templates. If you create an empty project, you don't have anything
and you should create from zero by yourself. You can build your
project any time from this menu, Build, Make Project. When you press it, it takes a few seconds to a few minutes
to build your project. If you have any
errors or problems, you don't have this screen check and you have those errors. You can see your building
process in this window. And when you even press this Run button to run your
app and see the result, you can see in this window, how is the building process
and what is going on, okay? Let's minimize this window. You also have this
resource manager that all of your
resources are here. For example, even
your colors are here and strings is here. You have your files. As you have your hard drive, you have them in here. For example, this main activity, you have it under that folder. Any time you lose it
and you want it again, you can't double click
on it and open it. All of the other files in here, you can access them In
this project window, you have all structure
of your project. All project file that
you have are in here. You can see all of these
files on your hard drive. For example, if I write, click on this and open in Clare. I have this on my
hard drive. Okay? I open the app, I have the SRC. I don't have them in here. Why? Because I should use this drop down and change it to project. Okay. Now now I have the same structure libraries
and SRC in here as well. If you want to see them in here, you can see under
the Fuller libraries RC for the source
exactly the same. You can also change it back to Android structure that
categorized them as recommended. Not exactly the same
on your hard drive. Anyway, we stay
with Android view, we have all the
other views as well. We stay with Android
view because most of the programmers
use this view. It's easier to understand
and easier to use. Okay, long story short, we have this file and this
activity, that XML file. Cutlin code is our
programming code that we defined what happened if
anything else happens. For example, what if
user click on something, user enters a certain page? What if user do anything else? But in XML files, we define how should
the app look like. For example, you see this is how our app look
like at the moment. A text with amount of hello world at the middle
and a big wide screen. If we have an APK
file and in a solid, on an Android device, even not a phone, we have a screen. A text with hello world. We can even change this. You see all these XML text. We can change all the
attributes of the texts. For example, we have text inside that Android hello word. Don't worry about
the other things. We explain all of them and many other
things in the future. But for now, for the
simplest way of have an example high
with capital there. High there. Okay, Let me
back to preview page. You can see now I have
high there like this. I changed the text. If I change this text, I can see it on my app. But what if I want to use the click on a button and after that I show
different text. I can't do this inside. And ML, I do this on
cutting inside here. I say if a user click
on that button. So change that text
to something else. This is the difference
between XML and Cut Ling. I hope you can understand
what I'm saying. In the future. I give as
many as possible examples, you can understand
it completely. Well, before I forget, if I have some
resources, for example, images, for example, some
texts for different languages, for example, pictures
or anything else. Do you see the resources full inside that you can have
all your resources. For example, if you have some kind of text or
even defined colors, you can put them in here. You have the color
emer file to name your color that you want to use in different
parts of your app. For example, as you can see, you have these color name
black with this amount, you can see Preview on the left. This is color
black, color white. With this amount you
can see color white. Preview also a string, you have your app name here. You can also put all string values that you want to use all around your app. For example, some for your
buttons or anything else. I hope you can understand
it for now. Let's move on. Besides these values,
let me quickly show you your app icon will
be saved in map. As you can see, your
app layout file will be there in layout folder. As you can see
many other things. As I said before, I forget from time to time
you might have some errors, but there's nothing
wrong with your app. I might say this a few more
times because it's important. You just have to came inside, build and make your
project again. Rebuild your project. You can use make project
or maybe rebuild project, whatever that works for you and you might have
no error after that. Sometimes happens,
but not all the time.
6. Day 1: Completing The First Project (Part 2): '. Okay, let's continue. I want to add a button
to my app like this. I want this be below this text. And at the middle I
connected to right left. And this text I also, you can see this
attribute in here. Open this attribute
from the top. I add 50. 50 is good, Yes, and you can see 50 DP
margin, top 50 DP. Let's find out what is DP
dimensions in Android Studio. What is dimensions? Dimensions value
defined in XML or layout files is specified with a number followed by a
unit of measure like this. What do we use it
for for distances? For example, in here, margin top equals 50, it means you should add
a margin top for 505050. What is DP? Next slide, we continue to explain this. We have different
measurement units to define size and distances. As you see, we have pixel
inches, M, M millimeters, T points, P density, independent pixel, and
SP scalable pixel. But the most used ones in
Android are DP and SP. You can read the descriptions
for more information, but which one is better
for what anyway? Recommendation use P for text. Use DP for other dimensions
and sizes like margin, weight, height,
and other things. Let's know more about DP. If you have two devices with the same resolution but different screen
sizes, for example, 5 " and 7.1 ", the density in the bigger screen is lower than the
smaller screen device. Because of this, if we
use DP for an image size, that image will be bigger
in the bigger screen, but in the smaller screen
density pocket. All screens are grouped
under density pockets. Mdpi and others that we
can see in Andre Studio. You define what screen, which of these pictures. I think again,
it's intermediate. You can came back here in the future if you don't
understand any of these, even when you want to put
your icon in your app, there are sites
that you can give your picture in them and they
give you all these sizes. Even then if you
don't understand exactly which picture for
what they create for you, all of these things, this
table as you can see. You don't have to remember
all of these numbers. These are for more
information to know about which size is better
for different screen sizes and what is the actual size of same image in
different DPI screens? Nothing. You don't have to
memorize all of these things. Don't worry at all the images except app icon stored in drivel folder
in Android Studio. As you can see, we
have these sizes. Again, recommendation
always provide all density buckets for all the images that you
want to use in your app. What does that mean?
It means if you don't have some of these images in
one of these follers closes, size is found and used. What I make it clear if you don't provide
one of these pictures, it goes to nearest
folder, for example, if you don't for white
this, it goes here. And look at this, you
don't put it here. Okay. Go search in here. Then it find it in here. It resize itself because the
Android resizes by itself. The quality damage. It's not the same as
if you do it yourself. Because of that, it's
better provide yourself. You will learn more about these things
during this course. Don't worry about it. But for now, because we want to clear what is
DP or other thing, we cover all of these things. I said it again, don't worry at all. As I noted here, density pocket name will be at the end of the
related rival filler. You can see at the
end of each of these. That's it. Let's go
back to Android Studio. Okay, I have a ID. What is ID? It's the name that
we call our object. For example, if I
call this button PTN, say it said, what
do you want to do? Every place that
use your button, you want to change
them with BTN. Say I say yes, for example, Delete that high. It also said, All Peace, that uses your button and say we use it with the name BTN. Say hi. Do you want
to change it to BTN? Say I say yes, because all places inside the app known this button as BT. And now I changed the name, so they should know about this. I changed it all places,
press that button. We explain more about this
window in the future. Okay, we changed here. Now if we see in the code, you can see this button
ID is equal BTN, say hey. Now I can see this
text is button, I want to this text say hi to us. There you can see it's changed. I want you to see. You can change it from this, from here I changed the idea. And also from this place code, you can see that the I just changed inside the T. You
can change it in here, but I want to see you can do it from the XML view, text view. Okay? Okay. Now,
what do we want? If I click on this, say hi to user, change this high user
to different texts? How should I do that?
I inside XML file. As I told you, we need to
do this kind of thing. If I click on some
should happen. This kind of things I should
do inside file file, okay? Okay. Now I want
to say something. If that pattern clicked here, I want to execute some code
for that inside out pattern. We have this attribute click. I write the name BTN Clicked
inside this lick event. But it's under the attributes. Anyway, attributes or event. Let's continue. You can see
this click inside this code. You can see this here. What does it say? Say you don't have this method
inside your cut ling. Okay, What is the suggestion? Create this inmate activity. Okay, let's create this
Android studio created for us. Inside it, you should
write some code. Okay, let's create a variable. Variable, it high, that is a text view. Tens inside the widgets. Create a text view as
type of text view. I should feel it. Find view, I find view ID. I should say which
object is belonging to this variable R. R stands for resources ID. As you can see, I can see
all of them text high. Okay, now we want to
do something high. What should we want to do? We want to set what
you want to write. Finally, say hi for the
first time, we say hi. As you can see, you
say this yellow line. It's because we can do this in many different
and better ways, but we just want to click function so we
can write our first. Okay, let's run it. Okay. Our app runs about, I think, one, 15 seconds
or one minutes later. You can see we have this button, and if we press it, we finally say hi. It's enough for now, because as you can see, we have many other
things to talk about. For example, we don't know
how to create variables. We don't know what is function, how we find these
things inside resource, why this warning is here, and what should we do,
and many other things. In the next lesson, we should start with basics. We cover basics one by one, and then we came back for
more complex programs.
7. Day 2: Day 1 Quiz Answered: Okay, let's answer
our Thursday quiz. Question number one. What is the best
installation order for the following necessities to act development in
Android Studio? We have CK, Android
Studio, and JDK. Since we in previous
video in day one, we have first our JDK, then Android Studio,
and then SDK. Very easy. Question number two, why
do we use emulators, of course, to preview
our apps before we install it on a real devices? This question number three, when does the event, I'm sure you can
say this easily. When we click on a
object in a page, the click event is called. For example, if we
click on a button, as you saw in previous day, we use this click event
to change a text. We can use it in
many different ways, but of course you can first define what do you want to do.
8. Day 2: Create the app (Empty Project): Welcome to day two project
simple calculator. What will it do? Our calculator
takes two numbers, does four main
arithmetic operations, plus, minus, division, multiply, and show the result. If I enter one number
here, one number here, and press any of
these four buttons, the result will be here, East. That what will you learn? You learn at least these four
things define variables, different data types in Cutlin,
operators and conditions. Since we're on a project, we're creating this project, you will learn many
other things that will come up as best as I can to teach you many small details that you might find very useful. I hope you enjoy. Okay, let's create
our first project. When you open Android Studio, it may open the latest project that you were working on it. If you don't see this window, you can simply open this
menu file Los Project. Now you can see this
window in this window. You can press this button. New Project. Okay, This is your
template window, the window that you can
choose, any template. Anyway, On the left you
have the television. But we chose phone and tablet. You have some templates in here. Each of these templates
have something for you. For example, template
have a back, this template have
a back button. And this button in the first, we have this because we want
to do a different thing. We start with no activity. We create one project
with this one project, and now it's time
for no activity. Let's see what we have here. We press next or double cconet. Okay, We should write name. Okay, I write this name
for my calculator. My calculator, this is my
project name, package name. I write this honestly, the Android Studio
write it for me because I write
these things before. And since my name is my
calculator and Studio write it, I didn't change it. As I said, it's a unique thing. This package name, like your phone number or
your postal code. I said this also in
first day save location. My project saved, as you
see name my calculator. Since I saved my
previous project in projects, the Android Studio. Yes, I want to save it in my
calculator on the project. As I say, my last
project in there, language cling why
Catlin because Google Android Studio
suggest Catlin is better. I chose Catlin for
my project now, minimum K. My minimum
K is Android seven. I can't install my app
on device if it has, for example, Android six. All the Android after seven and Android
seven support my app. And it's about 96.3% devices. It's a good number. Anyway, configuration language. Since do recommend this, let it be this and finish. Since I just created my project, we wait for a few seconds to a few minutes until the
gradual build my project. Okay, my app bill
is successfully completed in 1 minute
and 5 seconds. As I said, it might
be different based on your Internet and
computer power, like Ram or CPU. Okay, let's continue when
your project is ready, let's see, what do we have? We have two main
part in the project. This project that we
can close and open, and this main window that
we have in the center. We write all our
coding in this place. In this main place, the project section
that we have in here, be sure that you select
Android for better access. You also have this
project view that shows your project the way
that stores on your hard disk. Anyway, we cover all these
things on the first day, Okay. In the Apple, these
three pollers manifest, Catlin plus Giova and resources. In this Catlin plastiovo, we have this holler, since we didn't use any
template, it's empty also. We have these resources. We come back here later. We cover some of these
things in first day, we want to add a new activity. We continue this in next video.
9. Day 2: Add an Activity in Android: Okay, welcome back. Adding activity to our project. If you're not seeing
this like this, you can choose option three. Appearance compact
medial packages this. Don't you see this? But if you check,
you see like this. Okay, let's move on. Right click in here. If you have like this, right click on the last one. New activity, empty Activity click.
Okay, you have this. We are now adding an activity. Let's look, what do we have? What should we call it? Let's call it Main
activity because it's our first activity and
its main activity. Actually, each
activity has two part. The part that you type your, the layer that you see, we call it layout. Because of that,
you have two names. Mostly you have the same name. You can find which layout
belongs to which activity, you can find one while
looking to another. You see there's a different, slightly different
in the naming. Be careful, you can't
write any space in here. Layout name is not set to
a valid resource name. Space is not a valid file
based resource name. You name only
contain lower case a to Z and number zero
to nine or underscore. That is this, you should name it as it should
be, not anything else. For example, you
cannot put a.in here. You can't use capital like
this because of that. As you can see, you
have Big M up there, but you have a small
characters down here. Okay. What is our package name? Our app package name, Of course, what our language
for coding Cut. You can also click on Job. In this course, we use Cutlin, but we have also
one other thing. You see this launch
activity. What is this? Then you click or touch, let's say touch
on Android voice. Then you touch an icon in your Android voice and
launch an application. You have a default activity. Every app has a default activity that you see when your app open. If we check this
launcher activity, this activity considered as launch activity as
default activity. We check it because
it's our main activity. Okay, nothing else. Let's finish this and wait. Our activity will be created. Now we have this
main activity at this activity on
the line XML that, as you can see, has our
reviewable activity. This is our main
activity, Katie and XML. Before I forget, let's
change it to compact, since I just like to disk you. What happens if I close
this and I close this? How can I find them? First project then,
Not this android view, The clesva, my package name, main activity, double leak. This is K has my code. Then under this resource, I have my layout on this. I have my activity main XML. Okay? I have this
manifest up here. Inside that, I have this
Android manifest XML. The easiest way I
can explain about this Android manifest that
M. This is our foundation. It is our base file, the most important file. This XML file contains important metadata
about your Android app. This data includes, for example, package name, activity names, what is your main activity? And lots of other thing. Long story short, it's
the most important file in your project that
everything starts from here. We have lots of things to
do with this in the future. For so many reasons, we will come back to this. But for now, let me
explain some of them. What is our app?
This is our app. What do we call it? What is my app name Or what is my team? But we're not here
for these things. We're here for this activity. Every activity that you add to your app has
an entry in here. All of the activity
in here, for example, we create an activity, we have it in here. We activity that we
added its main activity. We check it in just a second. Let me continue with an example. Right click in here. New activity, empty activity. For example, I create an activity named
logging finish. Okay, I have this logging. Let me back to this. As you can see, you
have this name logging. This is the whole code that inserted in our
Android Manifest ML, the three lines, the
name and exported. Before I forget, you should always start your
activity. It's the rule. It's not forced by
Android Studio, but it's the rule. New activity and
empty activity here. Always start capital letter. It's important as you
can see capital M, capital M in here. As you can see, capital capital, it might has many parts. For example, main with capital and activity capital also each word with a capital. Another thing you can see login, Since we have one
login for our code, we have this activity
with our viewable part. Our layout is here. Activity naming and
layout naming routes. Let we see what do
we learn until now. Activity name, we start
with capital letters. If you have more than one
word in your activity name, it is better to start each word with capital letter
for more readability. For example, activity
logging activity, Can you see the capital A
capital The word Activity at the end of the activity
name is optional but but recommended layout names, you can only use lower case letters A to
Z numbers zero to nine. And underscore in layout names, white space is not
allowed because it's not in and all
the other characters. The name of layout
file should be the same as related activity. For example, main
activity activity, you see the relation, you can see more of these
things in the future. We explain all of
them many times until we can be sure you
understand all of them. But this is a very
brief explanation of what we are doing
in the future. Okay, let's go back in many. First, as you can see in here, we have just these three lines. Why? Because we don't
have the launch. Our new activity isn't
our our main activity. What if we want to change
our launch activity? For example, I want this logging activity be the first activity
that everyone sees. First, we close like this. And between this
part, as you can see, this intent should be between this and this part. We cut it. The control X, and
exactly in here, we pay control in here. What do we have? We have
this red under line. Why? Because a launch activity must be exported
as of Android 12, which also makes it
available to other apps. If we make it, the error will go and your login activity will be
accessible with other apps. Anyway, I hope I can explain it. Well, let's change
it back to here. And also, we don't need
our logging activity, let's just remove it. We delete also delete
files, this login, we can delete it
from here or just press delete button safety, delete search. Okay, of course. Okay, delete anyway,
because we don't use it anyway in anywhere,
this activity login. And also press Delete, and of course, delete deleted. We will continue this
in our next video.
10. Day 2: Create Layout - Part 1 (Constraint Layouts - Edit Text): Create layout part one. Okay, Let's continue
where we just left. I just checked my videos and I think my funds might
a little small. I should make them bigger
for that, I choose. May you file this setting? As you see, the short card
key is control and at the same time I
search for the fund. In here I can see first
I have this appearance. I make it out 16 apply. It makes the whole
app a little bigger. And the editor for my co part, I have the fund here as well. I think maybe, let me
see if I give it 15. No king, how is it? It is really good. It's better. I
think it's enough. Okay? Okay, I hope
it's better for you. And you can easily read this. Okay, let's continue
our coding and project. Okay. First, close this and let
me see if we run the app. We should see our activity
on the line main ML, we first our emulator. We have this emulator
we selected. Okay, now I should press this. Run and wait. Okay, my app runs
and my app runs. You can see this is our app. Avoid and the name
my calculator. This is our app. Okay? Let's stop that
and minimize this. Now, if I close this, I first want to see what's
inside my main activity. Set Content View,
What does it mean? It means set the
activity content from a layout resource to show
which layout is for this code, for my main activity
from Resource. From Layout For. As
you can see here, activity underlying main is
my activity for this code. If I want to access this file, I just press Control. I'm on my keyboard and click. You can see the
color is different, it's look like a link. Now click and now I have
my XML that I saw in here. If I close it again, press control. You
can do this too. Click I see the Target Activity. Long story short, when your
activity class is open, press control, Click on the
name and access the XML. Let's lose. And let I have just this layout and split so I can see the code and the
view at the same time. At the default, we have
this layer on our layout, this constraint
layout that we have, this layer name
constraint layout. Starts from here
and ends in here. You can see if you
want to end it, you just add this at the end. It's the same but
this is extra you add if you want end this
called closing type. When you add this,
you can't close this. Layout layout in Android apps. Layout Manager are used to set the position of child
views within the UI. You can effectively display your content using the right
combination of layouts, we will teach you all of this. Android layout is used to
define the UI that holds the UI controls or bridges that will appear
on the app screen. All the elements in a layout are built using view and
view group objects. Every application
is a combination of view and view group. Every application
view and view group A View is defined as
the user interface which is used to create
interactive UI components. Ed, image view, text view, radio button and all the other. Is responsible for
event handling and generally called widgets. We call them most of
the time, widgets. A view group act as a
base class for layouts. Layouts, parameters,
holes, other views, or view groups defines the layout properties,
generally called layouts. Don't worry if you got confused. We teach them the best way
we can during the course on the Android Studio types
of Android layout, linear layout, relative layout, and all the others. Constraint layout
is a view group. It used to specify the position of layout constraints
for every choice. View relative to
other view present. A constraint layout
is similar to relative layout, more power, okay? Okay. Okay, let me show you
what is constraint layout. Constraint layout can work as a parent layer to
add your elements. For object in constraint layout, the position of each element is determined relative to
the other elements. Let me explain this first object connected to top right left. Second object connected
to top right, left. What happened if I move this first object
just a little bit down? For example, I bring
it down until here. What happened to
this object will be as much as this object down. Why? Because these two
objects are relative. This isn't relative to this, but this is relative to this. Do you understand what happened? Whatever happened to this? Go down or up. The second object will be follow the arrow connected to the
parent or relative object. Whatever happened, they affect
each other as the arrows. I make them do this. Okay. So what happened to
this bottom one? If I move this one or this one, can you guess nothing? Why no arrows between them? This isn't relative to them. During the course, I explained it better
on Andrew the studio. But I insist you focus on, on these arrows. How are they affected
by each other? I explain this one
more time quickly. This first object moves and the second object
move down or up as well. Because this arrow and the bottom one not
affected at all. Okay, let's continue. We need two box that
take numbers for our calculator from
the user added text. A user interface element for
entering and modifying text. User can enter any
value in this text box, but the type of text can
be restricted using text. Edit, attributes, It attributes, you have all these
attributes and many more. These are most important one. We cover these during
the course many times. We can be sure you understand each of them and
know how to use. Okay, let's add edit. What is edited is a
simple that user can enter any text in it if I
want to give the edit text, these two properties, as
you can see, the edit text. First, think at these
two because these two is the most important
properties in edit text. I should press in here, I want to Andre tells me what options do I have,
Control and space. It opens the options, I can choose between these,
it's called intelligence. Anyway, I choose rap content. Most of the time you choose
rap content or match parent. Some other times you
choose other things. But most of the time these two are that we select match patent. The height or width of
the object will be the same as the height or
width of its patent. You can see how is the width
in this example content, the height or width
of the object. I mean any object, any object will be the
same as its content. The more content,
the more height or width, and why versa. You can see the width example. It is really simple. Okay? Wrap content, okay? Wrap content for this as well. At the end, this slash, because I want to close
this edit text as I say. When I click, for example here and press Shift and this button, it shows me the
options that I have. But if I click anywhere
else and close that, if I click there again, I don't see that for that. As I say, I just should
press control space. This helping window opens again and helps me to choose
what do I want. For example, we add edit text. If I want to add a button
just down with my keyboard, down button, inter add a button. Okay, I delete. Delete. Let's continue
this in the next video.
11. Day 2: Create Layout - Part 2: Create layout part two. Let's continue. Don't
forget a close your tag. You create edit text. You must close it, even you create this layout. You must close it like this. Lose. If you don't
lose, you have error. You lose. It's not option. As I said to say, just press okay, this
helping window comes up. What do I want? And
text and wrote, let's say this text
equals some value. Or the easier way. Let me delete this. Easier way is right. Android Studio helps
you all which contains, I want this Android. I choose this one easily. And my value you see. Let me hide this and zoom. I can see what do I have? A little bigger. Okay. Now, if I change this to match parent,
what do I have? Its it matches its parent. That is our layout. It takes all it. But let me change
it to rock content. Again, rock content, just
how much the content, I mean, this text
needs for displaying. If I add some text at the
end of it, for example, some of the you can
see it's going bigger. And some numbers maybe
you can see the changes. If I have the match parent,
there's no difference. So I have this text
or just the value, no difference is
came from parents. I hope I can explain it. Well, let me see. What do we have if we change
the height to match parent? Pause video and guess, then play the video
and I'll show you. Okay, let me see if change
this to match parent, the whole height belongs to this edit text from its parent. Be careful, if the parent only
occupies half of the page, then the height of the
edit text will only be up to the middle of the page. The weed and height
come from the parent, since we have the layout
all less cream, top down. So we have our
parent sized parent. Okay, let's change it back. Rack content for our calculator. We need something like this. And just so you know, most of the objects has
this wet and height, almost all of them. Let me say most of them. Okay, let's continue. But we have this red error, this underlying red
under this edit text. And also we have this red error. It says you have an error, you should fix it. How can we fix it? What is this error? This error said you add
your edit. Nice job. But. You don't specify where should we show this?
What does it mean? It means you should say
from at least one angle, it connected to something else. So the Android, when
you run your app, can decide which side of
your object connected to which side of what object
can sort it out somehow. Let me show you. So you write to top of and you have the A layout
constraint top to top of. I chose it and I said the top of my edit text should be
connected to its parent. We can specify an ID if we
have another object in here. But no, I want to say patent. What is parent? My constraint layout. My layout. Okay, if I do this, you can see this blue. My upper side of my
edit text became blue. It's connected to upper
side of its parent. As you can see, it's
not Android, it's app. If I do this inside
design in here, I just can click in this circle and move it a little
left and leave it. The Andrew Studio, just write
this layout constraint. Start to start of parent, We can type it in here, or we can do this here. In design mode I do. So you can understand
what is the difference. Before I forget, you can see you have all
the text in here. You have the attributes in here. See lay out what match parent, lay out Id wrap content. You have all other things, even text this value, If I say value, for example, this
number at the end. And in there you
can see this text changed to this I write in
there and it added in here. Whichever is easier for you, you can do from there. I hope I'll explain
it easy enough. We don't do with all of
these things for now, but you know these
are able attributes. Also, you have the attributes. These all attributes
contain all attributes. You can see if I press in here, these all attributes will be open and all of them in here. But the usable thing, the attributes that
we use the most, are these few attributes. Most of the time we use
and work with these. But sometimes in the
all attributes we have some other thing that we must work with them
in the certain time. Okay, let me minimize. What do we have here? At the right, I have the circle. If I drag it in the right, you can see I have layout
constraint to end of patent. Just so you can see, what does we call the bottom? I drag the bottom one to
the bottom of patent. So you can see layout constraint bottom to
bottom of patent. Because we connect up
and down to the parent. Our edit text came
to the middle. If I want to delete, for example this bottom one, I can remove it from here, Pt, the bottom one is gone. Since this is very useful, let me do some other thing with this that we learned so far. Let me connect it
again. This time. Remove top this line. Remove it, it's go down. Let me reconnect it,
it middle, let me see. Wrap content. The width of the edit text is limited
by its text value. If the text becomes longer, the width increases and
then again match patent. You can see it's really easy. You just should work with this. The more you work with this, the more you learn. Long story short, what
does these four things do? You can see them
inside attributes. In here, these things
shows you where your object should
be inside your view. L XML or your view,
or your layer, whatever you want to call
it in the Android device, should your app look like, how should your object
be side by side? Because we work with
these things a lot. I try to explain them
as best as I can. Let's continue this
in the next video.
12. Day 2: Create Layout - Part 3 (TextView): Create layout part three. Okay, we'll come back. We cover these and we don't need this one also. We remove this text because it's our first
input in our calculator. Now I have three warning above. As you can see. One
of them is autopi. Okay, let's autoph, go to Feel Hints. Feel hints for example there. Okay, What is this auto fill? It's for something that
Android might fill it for you. For example, user name, e mail, or other things. It's not necessary for
the calculator edit text, but we fill it anyway
because I want to show you how
reduce the warnings. Now let me look at this again. I need input type and
accessible label. Now we have two ways
in front of us. First, we can see
the warning up here, for example, this label. Or we can go on this edit text. You can see this
yellow underline. You can see this missing
label for the hint, hint or label for one of those. You need one of those. Okay, first let me write
this hint, this hint. Put your number here. No, your number
here, it's better. Now it's hint. You guide the user that
what should he do? He should enter the
number here, of course. Enter your first number here. Let's run the app by pressing
the button and okay, our app is now run on
our virtual device. As you can see, it said to me, Enter your first number here. This is our hint. When you click on it and you
type something, it gone. Why? Because it's just a hint. If I remove it, I
still have my hint. But if I write anything, the hint is gone. My number or my text will
be replaced by that. Okay, let's stop the app and
of course minimize this. Okay, let's continue. Okay, so now you
familiar with this hint. Let me add the label
first I delete this, then I add the text view. Okay, text view Evi jet, which displays some text on the screen based on the layout, size, color, et cetera. You can write any
text in this element. What is text view? This is text view. Anyway, attributes
for this text view, we have some attributes
like what is the usage? As you can see
during the course, we cover these many times, as much as we can be sure you understand them well because it's the most
important thing, you should understand them well. Okay, let's text view. This is text view. Okay, I have my text view. And of course rack content. Rack content. Now
what else I need it? Text. Okay? I write first number, of course I need closing and I should connect this to top
and the left of its parent. So I can either connect these circles to the
top or the left, or just write the
code inside this. I connect to the top
and to the left Patent, Patent, and label. For? For label for what? Some ID. But my edit text
doesn't have an ID, so let me add ID
for my edit text. Instead of typing here,
use attribute ID. For example, x. Now I have this xt value. Now I can give this exact
to this labor form. Now, before I forget, I add text view. This text view is for
showing any text, not editable text by the user. User cannot edit this
text by clicking on it, but edit text is for input, this text view not for input. What do we have next? We have other
warning input type. Okay, let's fix this as well. Input type. What is our input type in
a calculator, of course, number, the user only
can insert number. Now as you can see, we don't have that
line yellow under line for the warnings
because we fix them. Of course you have this
warning because you must put it inside the value
file and other things. We reach to them in
the future lessons, but don't worry for them
now, let's continue. Now, let me run this again. We have the and when
I write numbers, I have this first
number on the top, okay? Stop and minimize. As we can see, they were
too close to each other, it's the problem, okay? I add this ID first
input for my text view. I change edit text
ID two EDT value. It's my mistake because
it's edit text, I should start the name EDT. Since it's texts written
law between programmers, I should write T
first input now, instead of from the top, connect this to the patent. I want to change it. Control space, top to bottom of top to bottom off to bottom of kicks The first input as
you can see on the view, this part connected to the
bottom of this text view, so it's connected to the
bottom of the text view. I have this error y because I write this thing extra idolated. Okay, let me see. I have another error. What does it here? I have touch target
size to a small, it is to a small, it needs a little more height. Okay, let me fix that as well. Now I put mean height to 48 DP, so my edit text
can't be a smaller, the height of my edit text
can't be smaller than 48 DP. The result is user
can easily touch it. If it's smaller than for ATP, it's hard for us, some users to touch it and
select this edit anyway. As you can see, we fix
this error as well. Okay, let me quickly run it
again to see what happens. As we can see, I have
this first number, I can write number. This is saying first number. This is our first number. Unlike our hint, it doesn't go anywhere When we write
numbers and any other thing, If we write any other thing, it doesn't go anywhere. You can understand. Now what do we have
this label for? We said this that we
write what does it for? It's for this edit text. Because of that, we said
it's label for this idea. What is this idea ID
of the edit text? I hope I can explain it. Well, before I forget, you don't have to
run it every time I run it a lot because I want
to show you what happens. Okay, we don't have
the second number. We can use this to put the
objects on the screen, or I can show you other thing. Click here, the when you
press the left click, you can use middle wheel of your mouse to screw
it down like this. Okay. Now, release it. Press control C. Can you copy the text now? Control me what just happened. You create a copy of this
text and this editas, but we have a small problem. What we have these IDs, we can't have duplicate
ID in this view. We should change these IDs. What do I change this ID? I change it to 62nd
input the text. I changed it to
second number label. I changed it to T
second value because I changed this edit text
ID to edit second value. We already set mean height so we don't need to do it
again because we copy it. And to the bottom of 62nd input to this as easy as that. Okay, look at the right side. You can see these are
on top of each other. It's our problem. We have a problem in
here. Let me zoom. And as you can see there on top of each
other, what can we do? First, let me change
this edit text value. I changed it to it first value, I changed it to it first value. Now I should change
this label for first value as all of our IDs is good for now. Now let's change their position. How can I do that? I want this text view be at
the bottom of this edit text. I change it to top of this
text view connected to them. It fire bottom of this one. You can see this connecting
to the bottom of this one. Okay? And this edit takes
the second input, bottom of what do
we have here now? This text view and
then this edit, this text view and this edit
text. Let's run it again. I run my app again. As you can see, I
have my first number. This is my first number
and my second number. This is my second
number. Okay, Don.
13. Day 2: Basics of Material Design in Android: Material Design in Android. I run the app, but as you see, I still have two errors here. However, my apps can run
how some errors are, just in the design part
or XML files related to layout and can't prevent
from running your app. It means they don't stop you. Instead of fixing these errors, I want to make my
app more beautiful. Let's see how I want
to do this, Okay? Material design, a
comprehensive guide for visual motion and
interaction design across platforms and devices, create beautiful and
usable products. Using material components gives you more control over how
your app looks to the user. Makes your application
interface, user interface more
beautiful and interactive. Saves your time. Many features that
you need are already implemented to use material
components in your. Be sure you have this line
in your gradial file. Remember, version 1.11 0.0 may vary depending on the
time you watch this video. What does that mean? It
means version 1.11 0.0 is the minimum version that you use in the future you came
to this point and this line, minimum version you
use, is this. Why? Because you see this
video in the future. And the version that I
use at this time is this, your version is equal or higher
minimum version is this. And of course, minimize, okay? Let me move it a
little bit here. And zoom it with this hand
right here, about, okay? So what should we add in here? Margin. Okay? A margin.
How much margin? For example, ten DP. Ten DP, or copy this. Copy exactly this line
to the other one. Okay, let's run this again. So my app now as you can see, I have this space around it. We can have more space. Let me show you. Okay, let's add a little more,
for example, 30. 30 as well. Let me see what happened now. You can see my app now has
more space between these two. This margin at space this, you can do another number, for example 20 or 40. It's optional I think to start, it's good margin or external space used to make a distance between
objects in the page. To make your user interface more beautiful and
user friendly, you can define
margin for all sides and it lay out margin or
each side separately. For example, if you
want margin for two side and not the
other two sides, you can define it
for only two sides. Anyway, let's see the example for all sides with
the same amount. Each of these four
is for one side, For right, left, top and bottom. For example, you can only
have four top and you don't, and then you don't
have any margin for the other three sides. Okay. As we remove
that text views, we should show something
for helping us. We add hint, I add this hint. First number. First number. I copy this on the
second number. Okay, I just copy this
now. Change the text. Okay, second number now, as you can see on the
right. First number. Second number. Okay.
One more thing before I forget what is different
between text and that hint. I changed this to text and I still have for the
first number hint. Let me run and show you. Okay, as you can see it, write for me first number. And if I write 123, the hint will be gone
when I remove it. The hint comes back. When I write something
in second number, the text is still here
because I write this text. If I remove, I can
remove some of these, but I can't remove first number. If I type anything, the hint will be gone. But no, the text is the
value of the added text. Okay, for now, I
changed it to hint. Again, I change this to hint. Okay, let's run the app
and if I type anything, our hint will be gone. What happened if I have more
than two box like this? The more than two edit text, for example five it, ten edit. For example, for
register I have name, last name, phone, e mail, and many other things. What happened if I want to keep the hints and also
user can type text, text input layout, a material component
wrap and edit text, or text input, edit text. It's better to use it with
text input edit text. You can add style to it
with a style attribute. Text input layout
has some attributes, the most of them are these. For example, with hint, you can display hint as label some other useful text input layout attributes. For example, with lent, you limit the number of
characters that user can in text input, edit text, a material component
to get user input. It gives you more control over a style and how it should be shown to the user must be used
inside a text input layer, different styles to show
it in different ways. As you can see, it
looked like this. If you change the style, you can make the look like
this or any other thing. I'll just give you two examples. Text input text have
some attributes. Some of the most important in those attributes
are of course, ID supply as identifier to
access the object later. Id is the name. What do
we call this object? Almost in all objects we have this D many times it's optional. Most of the time we put an ID because we want to do
something with that object. Anyway, input type, for example, the type of data being placed in a text number and the
Oder, for example, if you give this
input type number, you can only put
number inside that. It means if your user try to put anything else,
this text input, edit text doesn't accept
and the user can only put number inside
this text input it. T. Let me add. Okay, what should I add? Okay, Text, text, text. This one congule
Android material, Textfield Text Input layer. Okay, I pressed in there, So I add this phone and
I want to control space, say match patent, and this
phone is rack content. Okay? Okay. Now
let me close this. Okay. As you can see, we still have problem here because you can't
close it like this. This, you should first
close this part. Then Andrew, you
close the other. For something like this, if you forgot, you
have that error. As you see, I still have
this problem error. Why? Because it doesn't
know where should it be. Please explain to me where
it should be positioned, where should it be placed or something like
this. Where should it be? Because I want to place it, instead of my first edit text, I should copy the constraints
from the first edit text. I have this position to here. Now we come down. I have this control x cut. Edit control X cut up, control, paste. Again, you have it
in here, control V, you have this edit text inside
this text input layout, see at the right is changed. Of course we should have an ID. What is our ID? It's input layout first, capital capital F. Okay, what Next you can see we
have this red thing here. Because of this red thing
here, we have error. Why? Because we say top of you should be bottom of
this it first value. You might say we have this
EDT first value here. But since it's inside
this text input layout, this cannot recognize
that this can only access to the outer
layers, not inner ones. Input layout works as a layer, What is the solution? It can't find this, but it can find
this input layout First, copy, control, paste. Now it's changed. Let me show you again Control. It doesn't know where it should be and it looks like this. As you can see, Control, look at the right control now. It, it should be under this. Okay? Until now, let me see
what just happened, Okay? We have this different
style, first number 123. Second number 123, don't happen. You can see one to
three don't happen. But here it's more beautiful and we have the
hint and minimize this. Minimize this and continue. I might pause, for example, minimize things you can see because I don't want
to waste your time. Do we love this
first number now? Yes, we do. What should we do? Go up, select this control C control easily. In here and slash, close it easily. Oh, input layout. First of course, change the ID. You can't have
duplicated ID Second, because I want to place the second number below
the first number. I should do this, copy it, and paste it in here. First number, second number. We have two added text. That is beautiful. Now let's run the app again. Now this is what I have. 123 and 123. And I have my, I don't like
the color of second number. I want it to be changed. Background White. Okay, I have white. Okay, What's the difference? You can see what
is the difference. Now let's make it
more beautiful. Okay, remove this in here, we give it style. I added style style,
base from base. Rigid material components,
text impode layout. I have this, let me run. This is our app 123123. Like this, you can
see the difference. Since we use this
text input layout, we can use different,
not just text. How we just tried input this for copy the side
from here and paste it in. Takes, takes like
this as you can see. Control. No suggestion. It should bring it for us. It's okay to copy this as well. And before I forgot,
it shouldn't be. Text. It should be
texting, put, edit, text. Since Andrew Studio
doesn't bring it for us, I just type it myself. Okay, Let me run this. Okay. What do I have?
First number like this? Second number like this. Oh, my text is like
this. What should I do? I think I give it
too much margin. For example, if I give
it 60 only and we said, now it's better. But you can see the
thing is design thing. You can learn these things. What should I do I do
to make it better? And other things
during your learning, you can understand
these things happened. What should I do to
make it right anyway? Let me copy all of the
thing down here to there. For example, I
changed my edit text. This change as well. The we have it here as well. I think 60 and sorry, I give mean height six. I should give it six. Okay. And these are unnecessary. And this copy and ha in here, okay? They're both are the same now. And minimize something
like this, it's better. I try to show you more
ways to do one thing. So you can choose between them. What do you like do in that way? I'll show you many things. Let me show you counter as well. I have this input text
and I have this layout. I add here counter as it should be true. What is this? Let me
run up again, 1234. You can see we have
this. What is this? We have four number. If I say 111, I have three, one
and something else. It's better to use Max as well. Max Len counter. How many numbers? Maybe because in the future you can see you have
limitation in the numbers. For example, can't have 500
number plus 500 digit number, you must have some limitation. Maybe ten, maybe 15, maybe 20 numbers, but you
can't have infinite numbers. You should limit
how does it work? First, let me copy this. Control C in here. Control, as I said, you see Edit Control, Copy and Paste Control. I do this from my
keyboard, okay. Run. Minimize ten number, 1, 2, 3, 4, 5, 6, 7, 8, 9, and 1 0, it's ten number. If I write two more one, you can see it became red
because maximum is ten. Okay. Before I forget, I should mention you can
see these things we added, for example, counter, counter enable and other
things, maybe even style. You don't have these things
on simple edit text, you have them inside these
more advanced added text.
14. Day 2: Quiz: Okay, welcome to day two. Quiz question. Question one. What is launch activity in
an Android application? I repeat, what is launch activity in an
Android application? Question number two, how
objects in UI are positioned? Constraint layout. I repeat, objects in UI are position using
constraint layout. Pay attention. You can
pause video and answer that or write your answer
in a piece of paper. Anything you like any way. Question number three. What is the difference
between match, patent, and wrap content value for
Android layout with property? I repeat. What is the difference
between match parent and wrap content value for
Android layout with property?
15. Day 3: Day 2: Quiz Answered: Okay, to quiz. Let's answer our questions. Question number one, what is launch activity in an
Android application? The very first activity
that runs when you open your app in
an Android device. You can assume it
as the default page in your Question number two, how objects in UI are positioned
using constraint layout. In constraint layout, the
position of each element is determined relative to the
other elements in the page. What is the difference
between match parent and wrap content value for Android layout with
property match parent, the width of the
object will be the same as the w of its parent. Do you remember from the course, it fits the parent wrap content. The width of the object will
be the same as its content. The more content, the more, the more width, and vice versa. As you remember, we also
see this on the course. I hope you answer
them all correct. If not, you can always
review the course. There are many more things
you can learn on the course.
16. Day 3: Add Buttons (Button Types and MaterialButton): Okay, at what? Okay, welcome back.
I just zipped out my previous day doors and I'll put it inside the lessons
so you can use it. Okay, let's continue
working in Android Studio. Use the icon next to the code blocks to
close the code blocks, or click on the icon
to open the block. What does that mean? It means
click on these to close the block and click
on the to open Del. If you click on, you have
something like this. And if you click on these, you have something like
this opened. Can you see? We press and press I
can also press the, Can you see what's happening? Press we minimize them. It's really better,
even the comments. We minimize the comments as
if we select these or these. You can see them on the right, but we minimize them. So we can easily
go between them. Remove extra. So it's all our code comment, this comment and this,
and nothing else. It's better, especially when you have lots
of objects in your layout. It's really, really better. Okay, now it's really organized. Now, what my calculator? Okay, now I added
two text field to get user inputs
for my calculate. Now it's time to add buttons to calculate different
arithmetic operations. We would like to have something
like this at the end. But what is buttons? Buttons communicate actions
that user can take. You can use buttons
in different places in your app user interface. Or for example, for cards, dialogues, model
Windows, tool boards or all the other button types. We have four button types. We have text, button, outline button, tiger
contain button. What does that mean? How should I know
which one is which? I give you some examples. You can see this,
it's text button, You can see this Outline button. Outline button looks like this. Talbot looks like this. Tgalbtens can be used to sell
from a group of choices. We have 123 choices, we want to choose two for that. We Galton user can choose any of and Contain button
most of the time we use contain button at the
moment in our app we use contain button In the future use other
buttons as well, other type of buttons as well. But for now I just want you to know we have these
four type of buttons, so don't be confused if in
the future we saw these, you say, didn't you say, we have only this
type of button? No, we have other buttons for now and later on,
the remaining three. Okay, let's continue. Material, A button
material, as we said. Contain button, That
is what we work with. This material button
has some attributes. Some of the most
important ones are these. As usual you have
the ID. What is ID? The simplest way, as I said, ID is equals to the name person
you call his or her name. It's his or her ID. The ID is how you
identify a team. Any button, this material
button has an ID. Other objects as I said
in Andrew Studio has IDs, any shows what button we
that shows on the button. We have some text
on the button for example pelos minus or other things that can
find on the attribute. Of course we have
other Add button, we can add button, but for now we don't add button. We add Material button for that. Okay, if I right, I have this Button Material. But as you can see, okay, I have this Google
Android Material Material. But this one I add
more advanced button. Okay, I added and wrap
content. Wrap content. And we, and this height, and we close it like
this, I have this error. Why? Because we're inside
constraint layout. What is the rule for
constraint layout? You should always
specify where is your object connect to connect
to left connect to where. We should specify that. We should say for example, upper side of this button should be to the down of
this. You see this? Let me do this again. For now, it's parent because it's connected to, but
I don't want that. I want it be connected to
bottom of the second number. I have this layout
constraint top to bottom of input
layout second. I do this without writing. I just want to show you you
can do in this way as well. I still have this problem. Why? Because I remember
at two direction, so one direction is left, at least two directions. So I want to do this without
writing any code as well. Just come here,
click, move it left, and release Layout
Constraint Start to start off what parent? Okay, I solved the error. I solved the problem for
this constraint layout. Okay, let's add another button. Material button. Of course we just copy taste. We have two button on
top of each other, but I want the second button to the right of
the first button, so they are not
top of each other. What should I do? You should add an ID first for
the first button. Okay? Id, Okay, BT N, so layout constraint. Start to the start of parent. No, we shouldn't
say even start of. We should say two to what? Yes, to end to end of who? To end of N. Look at the right. In the peer review,
the button is moving. This time it's to the
right of first button. So let's do this again. Copy. Okay, I have 123 and four button. Three of them as you can see
are on top of each other. I should add the ID
and do the same thing, but I think there
should be a better way. What do you think we continue the better way in
the next video.
17. Day 3: Basics of Linear Layout in Android: Linear layout. Okay, Let's arrange them
with the better way. What should we do? We should a L linear layout. Types of Android layout. We already talk about
constraint layout. We have many different layouts. Now it's time for linear layout. Linear layout is a group, is a view group that
aligns all children in a single direction,
vertically or horizontally. It's a very useful layout since that we want to talk
about it in this session. Okay, linear layout attributes. We have these five more
useful attributes. You have other
attributes as well, but we work with these
five very much of course. Id, supply and identifier, you can call your
object with this ID. It's look like a name for
a person orientation. You can say things should be
vertically or horizontally. Height. And of course, Gravity. We cover gravity in the
video as well in there. Okay, Of course. Content Content. I just press inter,
inter, inter. Nothing else if
you like to know. I mean three in in and
another in and another in. Of course, we can add
constraint layout. In this constraint layout, I mean any layout inside
the other layout. But I think it's better for this course and this situation
to use linear layout. Okay, let me close this, since I write this one, Android Studio, write
this for me now. I can put anything I want
between the start and end type. Like usual, we have error.
What is this error? It said you should specify
where should I show it? Why it's simple? Because it's inside
constraint layout. Constraint layout
rules said you have to specify every object inside me inside this
constraint layout. Where should I show them? At least you should
specify to anchor for it, you see for example
in the material, but specify two
places to connect, one for a start, one for top, at least two. If you put one, even one, you have the error at two. Anyway, we have this error
as well. Let me solve it. How many ways do I have one? Use this view with mouse click and drag to the
place that I want. One way is this second way. Come here, press Inter and start typing the
code that I want. Like this, a layout constraint, start to start to the bottom. Of all other things, this is the second
way, just type. But my favorite. My favorite. And as I can suggest it is your
favorite in the future. Come here. Oh, I love it. Control C. Control. I really do love it. We try to make it the best Android Studio and Catlin
course as possible. I try to tell you the most tips and tricks
as I can, for example. Okay, input layout second. There is Input layout, This is Input layout
second. But where is it? How can we find it? On the left bottom
of your keyboard, you have control key. Press that control key and
then move your mouse on this. If you click on it, you can see what does point to, what does it pointed to. Click it means, let
me try this again. This is my linear layout. It top is to bottom of
input layout second, but I don't know where
is the input layout. Second, how should I know? Press control, go and click. It shows you your
ID came from here. As easy as you see. Okay, what should I do next? I still have the error. Let me add another one. Copy and paste. Because I don't
have the third one. I just add. I should add another one or I can do something
else. Let me see. Instead of telling this my left should be connected
to the parent left, I can easily remove the
Look exactly and change my weight match parent since the weight is
from the left to the right and feel
entire possible with our left and
right position solved. We don't have any problem
for where should it be. Into the middle, into the
right, into the left. You add to solve this
problem, where should it be? But since I add
this match parent, the problem is solved. It is from left all
way to the right. And there is no other space, so I don't have to specify
my left and right. I still can, but
I don't have to. My error for this
constraint layout is gone. Now I hope I can make my point. So we have this linear layout. Okay. Other inter, what
should we do with this? We can select this and this and control X cut control. Paste all four buttons now are
inside this linear layout. Since they are in
my linear layout, I don't have this. Why? Because linear
layout doesn't need them. Delete the others will
be deleted as well. Okay, I delete all of them. You can see on the
right, I delete them, but there's no difference Why, Because it's linear layout. You can see if I click
on linear layout, it's said this is
my linear layer. It's a line. And the top to the
bottom of the left, right and bottom not
connected to anything. And all four objects
are inside of this and arrange like a line. What do I mean when I
say this is like a line? You see if I say orientation, I have this orientation
that is horizontal. By default, if I
change it to vertical, you can see all the buttons
are vertically to each other. Placed to each other vertically. But by default, they are
horizontally. If I delete this. It, consider it as horizontal. If I control space, right? The horizontal, they
are horizontal. If I remove it, let me show you the
default control X. Still the default horizontal. One more time, this is vertical. I hope I can show you how does orientation on the
linear layout works? As you saw in linear layout, we can't put two objects
on top of each other. Why? Because they are
side by side in a line. But as you saw in
constraint layout, we can put them on each other
as we do this many times. Let me show you better constraint top to
button control X. Now you can see the buttons and this
linear layout are top of the other objects on
this constraint layout. But even at this time, all four buttons are
next to each other and none of them are on
top of the other one. Why? Because this
is linear layout. Remember, please remember, you should know how
linear layout works. You should know how
constraint layout works. And based on your need, you can decide which one is better on the different
situation, of course. Okay, I have the A. Let me add the
other IDs as well. Okay, I already added PT and
I added now PT and minus. I added as well PTN division. I just remember I should
show you something else. You see if you click here, not just click, it's
click and not selected. So I just click Press
control C. On my keyboard, you can see the Android
Studio copy the whole line. As I say, the most important in this course is to show
you as much as I can, tips, tricks, and things. Why? Because I have many
years of experience. What does it if I can't
tell all of this to you? Okay. You can see I just
click and press control. See the whole line copied. I click here, just here. Do nothing, not
select, not anything. Not press Inter on my keyboard. So I just press control. We the Android Studio, add another line and do
the inhering for me. Add this thing I just copied as easily as you can see and
add it for me in new line. But I have error. What is error? This is duplicated,
but it's no problem. Let me okay, PTN multiply. I add this PTN because it's a custom rule
between programmers. It's not have to, but it's better to do so. I have this vertical and let me change it to this
horizontal as well. It's optional, as I say, it's the default horizontal. Okay? Okay, I have one more
problem and another tick. For that I want to show
you they are stick to each other and this one
has extra inter. This one is bottom of the thing and it's not
good. What should I do? Maybe see inter. I have many in and
many other problems. Even here, extra space, unnecessary space,
and bad writing code. What should I do, especially
when my code is really big? For example, you can see
I have only 116 lines. What if I have 500 lines? How should I arrange them? I can use menu code in here. Format file control
plus plus shift plus L. You can press on your
keyboard control Shift plus L or came to the menu code
and press Reformat file. Now Android Studio
show you this, you want to reform
file activity under LinemmL. What do you want to do? I say I want to arrange code. Do not keep line brakes. I want to do both
of these things. Run. Do you want to remove
custom line breaks? Yes, I do. I don't
check this because sometimes maybe I
press no. Okay. Yes. Now, what do I have? I have the spray
bring all of them but keep this one because I
add these inter myself. But you can see, for example, if I don't have the and they
are now stick to each other, you can see they are sticking to each other control shift and L, it said, you want to do
this I said yes, yes. It added these Ers
and arrange my code. I can now read my
code really better. It's a very useful command. I do this many times
in different projects, even in my code, I can use that to
rearrange my coat. I think you should know
all of these things. Okay, we should add some text
for each of these buttons, but we keep it for next video.
18. Day 3: Working with Texts and Strings (How to manage Stings values in Android): Text and strings
in Android, okay? This one, as you can see, our object has ID. And it's something regular, something steady, something common among
other objects as well. Whenever you see an ID, it means you give this
object a name like this, you have this text, okay? All the objects that can show a text on them have
the text attribute. It's works similar to
the other objects. You give it a t and it shows
you that text in your app, for example, we
have this property in the text input
layouts as well. And the other, let me
give it a value p, I give this plus, you can see this plus in here. Okay, I just copy this control. Why didn't I just press in
here and press control? Because I have extra
characters at the end. If I copy, I might
have to remove this. Okay, Paste. But this shouldn't be plus. I should put this minus as well. Instead of plus, I should
give it division as well. I should give it multiply,
this four multiply. Look at the right. You have these four buttons. Let me run the app.
Okay, I launched my app. You can see plus, minus, division, and multiply
look like this. But wait a second. I have this yellow line in
here and in here. Here, here. Second number, even here. Why I have all of
those yellow lines? What should I do?
Let me go on that. It said, hard coded string star should use a sign
string resource. What does that mean? It is
saying you should put all of your strings inside resources. As we can see, the
full resources. I press Projects, so I
can see the resources, the full named
values, open values. Okay, I open it, you
have the string. You should put all of
your strings inside here. Also, you can ignore it. It's okay, your app is running. Now you can see I run
the app. It's okay. But it's recommended you put
all of your strings in here. It is very useful, especially when you want
to use second language. Just imagine you publish your app and now you
have many users. Now you want to use
second language, Third language,
maybe ten language. What should you do? This string helps you in those situations. This string foil helping. It's great. It is
better and recommended. You put all of your
strings in here. Where to say strings, it's recommended to put
all your strings in. String foil in and
studio advantage. Easy to manage and mudiqly
your text and strings. Easy to add other
languages for your app. I mean localized string values. Disadvantage. None. You can see where are strings? You have strings foer under this fo you have stringr
after this thing. You can see the language
Exml structure. String values are
restored as a pair of name value inside
the string like this. You can see like this name, this is the name to
indicate which thing you mean to show in an
object or other things. Value mean to set or modify what should
be shown on the object. Remember the value is what you show to your user example. It's better. Okay.
And Roy takes, oh, it's good, equals string, this reference to
that string file we talk about inside that file. This inside that file, you look for the name T R, you look for this name
inside this string name, you had TR ad this name for the text
you showed this value. And if you change the
pelos character to, for example, this text add, now you have the
exact same thing. But when you run your app
instead of this pelos, you can see this app if you use it in many times
and many places, just you should edit this one and all of those
places are replaced. Okay, We change it to this, we talk about this name. We change from these to this, This is at this. Plus if you can see, I place it in here and
we change it to this. Everywhere that we use
this name like this. Now change, I hope
I can explain it. We cover it in the video, we can be sure you
understand it. What's inside this, it is
resources, start and resources, a string name, app name, my calculator, your string name. Each of your strings has a name and each of
them has a value. For example, you have a
string that called a name. This is your app name. The value is my calculator. How can we add this? I can click here
and press Control. Copy and control. Other control why? My first control doesn't
work because it is already selected this line
and the text that is, just copy it into this line. No difference but
second control. Add this another control control and I can change each
of these names and their values so I can use
these names inside my app. Is there a different way? Yes. If I want I can duplicate. Let me show you that
quickly as film. It control D here. Duplicate line. It doesn't copy your code and
then you want to paste it. It just duplicate
that line anyway. Control, control,
control, control easily and controls it
to undo what just I did. Either way. Let me quickly back to here. You can see if I go in
there, I have this lamp. What does this say? Extract a string resource. If I press this, it says, what does your resource name? And of course, you
can see the value, but what should you call it? Let me see what
should I call it. Okay, T R underscore ply. Okay. I personally
recommend this you add everywhere this SDR between before your string name. It's easier to understand. I press, okay, and as
you can see, a sign, a string STR multiply
inside our string file. Look inside our string file, go and find STR, multiply, whatever that is. Put it here, let me see. Str multiply the Android
Studio just added for me, what is the value S star? Anytime I want to use this, I can easily use it
many other places. If sometime I want to
replace it with the text, for example, we multiply
instead of this star. I write just in one place. All places that I use replace, you shouldn't have
many language. Even if you have
just one language, you can use this many
times, many places. If you want to change
it or correct it, you can easily do this
in here, Do it in here. We came to this string, XML. But what if I close? I don't know, where
is this axe string? I can show you. It's here. But don't, where is it? I'll show you the tick. Let me refresh your memory. You press the button left
down on your keyboard. The control button, press it. Move your mouth. If you click on it, it shows you Where
does it come from? Pre. It came from here. Even exactly, show you what
line you see. Lose it. Press exactly from here. It is really good. Okay,
let me do another. I have this, but I want
to do this with hint. Okay, I have the hint
in this text input. Okay, I have this. You can click or press Alt
plus In. What does it mean? Press Alt and it
opens this for you. Or you can press
in here or a in. It's the same. Extract
string resource. Okay. Our resource name will be
first number and the value, the exact text that
we write. Okay? I just add STR underscore, okay? And the yellow line. And if I press control
and click on it, this is our STR first number and the value is first number. Is it any difference? If I run the app, do I have my first number takes? Yes. You still have your
first number takes? No difference. You just
organize all of your takes. Okay. One more. I use the lamp or a inter, okay, to show you the boat. C, R score. Okay? Done. I don't press control and click, but as you can see, no difference. All
of them are here. Three to go. I'm not
doing these three. And keep them for next
video because I want to show you what is multi language
like in the next video. I cover that as well just to
be more familiar with that. We are not going to create a multi language because
we are just beginner, but we do this in the future. I just want to show you
how does that work. Join me in the next
video. Thank you.
19. Day 3: Introduction to multi-language Android apps and localization: Add strings for
another language. Okay, they come back. We have this Android view
on the top. You can see it. Android view Android. We change it to what to project. This is how your project looks like on your hard drive
where it's saved, okay? I open the app, I open the SRC, means Source, open main, this main folder, okay? I open RES resources just
a little bit more, okay? I have this folder values. I open it as well. Color string team, you can
guess color is for my colors. And this string has
all of my strings. So we have the resources
how to add another string that M change Android
View to Project View. In project window, you can
see this step two fine. R E S Foll under app SRC Fol. In this on the app SRC full, find this all your
resources, RS resource. The right click on the
resources and chose directory, this resources right click new directory, Step four, name. The new directory name
should start with values. Continue this character
with your target language, but not the whole. For example, if you want French, just if you want to use Arabic, R, it's really simple. Step five, copy the
current string XML file into the values directory, to the new directory. What you have, the values, these strings inside it. You copy that inside
the values French. As you can see, for example, I already have Arabic. You can have many language, as many as you want. Anyway, step six, back to the Android view
in project window. I mean this. Step seven, now you have another
language strings that can be easily translated
and modified. As you can see, you have
String, this is default. You have also Arabic and French. You can see this
has nothing after this default language
fixes in strings Em, I'll give you for example, English, E, N, French, F, R, Japanese, J A, and Germany G, E.
Right click here. And the resources, you see
resources S, right click. New directory now values. But I have values. Yes I have values. This is my values, it's my default values. My default values are English. Now what I want another
language, let me see. For example, they have right to language
opposite direction. It's good. A, R, Arabic, And press Inter. I have these values,
Arabic, R, what. Now, right click and
copy or control. C can here and paste. What should we paste? What do we have in here? This string? It's just
like our previous string. Why? Because we copy paste now what changes
project to Android. Now you have all these default string you, Arabic strings. You can see Arabic. And you can see the two
after the folder name, because you have two strings. Okay, let me translate
this Arabic. I just copy these. And I take it to Google Translate because
I don't know any Arabic. I paste it there and just copy
Result and bring it back. Wait, okay. Translated. Paste. Okay, my
calculator. And that is Star. But these two, these
are translated. Okay. As you can see, since I copy and paste
from Google Translate, one of my names cropped
it, what should I do? I go back to my original, I can see the copy and
bring it back in here. Our second number. Okay. If you have all
of these problems, it's better you just copy
this and this text and 1.1 take them to Google
Translate and bring them back. If you work in a company
with many other persons, it's better to give it to a person who works
as a translator, not just use Google Translate. I just use Google
Translate to show you how does it look like
it's not professional. If you want to do
it professionally, a translator should
do it for you person. I mean, anyway, it said
it translations for all locals in the translations
editor this pattern. Let me try it. Click
what do I have, these four keys resourceful on translatable
and default value. What does this mean?
My default value. Do you remember? I said
I have a fuller with my default and I add R. My default value
is the first number, my default value is
the second number. But my translated text
is this and this. If I have third language,
for example, French, I have one other column
for French, Chinese, Japanese, Korean, or many other languages
have all the other columns. I hope I can show you. What do I mean? Anyway, the just to be sure, we have this second number here and this
second number here. The name should be the same, only the value should translate, the name should be the same. Even if translator crafted, you should bring the name back. All the names are the same. Let me show one more
thing in this editor, this column table,
what does it mean? I have this star for multiply, but the star can't
be translated. I just have one star
in all the languages, for example, I just check this. My star just have
the default value. Let me show you other thing
in other ways, check this. See, I have this
start in here in Arabic and I have this
in here in English. If I remove this from here, for example, like this, I don't have it anymore. I use control if I want. Can I bring it back anyway? I don't have it.
What happens now? If I came back to the
values by defined value, I have this red line
because I don't have a translated name in there, so I have this red line. But if, let me close
it and open it again. Okay, this is star, I have this red thing. And it said, we don't
have it in Arabic. Said key K, R multiply has translation missing
for local Arabic. But if I tell it
it's translated, it doesn't have any translation. It's just a star in
all the languages. Or maybe plus division minus. Anyway, it isn't read anymore. If I come back here, it isn't read anymore. Why? Because translatable
equals false. It can't be translated anymore. I hope I can explain it well. Okay, now what? Now I have this and I want
to add this plus as well. What change you see. Resource name, Resource
value, course K, ST. I have this as well. Values Arabic. Okay, So I check it. I have checked in values my Default and my
Arabic version. I press this, okay,
And string CR. If I leave the mouse here, you can see default and
Arabic value as well. And I press control left
down on my keyboard. I move the mouse on here. Multiple implementation. Oh, what is multiple
implementation? If I click it, said I can't take
you to there. Why? Because it doesn't
have single place. It has multiple implementation. You can choose your destination. You have one in the values and you have
one in this Arabic. Which one do you want? I say show me in values, it shows in values. Let me try this again. Control. Click now. Show me the Arabic version. I have this in Arabic
version as well. If I leave the mouse
on the name, in here, I can see the configuration
in Default and Arabic, and each of the values for them. Just to be clear,
we do this to show you how can you
have two language, you have many other languages,
even ten languages. And as you can see,
it's really easy. It's really simple to
add other languages, but it's good for now and very useful instruction for how can I use strings. And because we are
in the basic level, we can't add language
in our app for now. But just for you to be
familiar with these, we cover these things. Okay? Just add the other, for example, the alt inter, STR minus and Arabica, I also add this STR
D in the stream, you can see a minus. I have it. And even multiply. As you can see, I don't have
that yellow lines in here, because it is now on the way that Studio and
Google recommended. Imagine that you have. Use this at 100 place or this
first number in 100 place? And you think, what should I
do if I want to change my, take this string first number? You can see I have the default value in here and this is my
SCR first number. I think I should add an
S at the end of this, for example, this first numbers. Or I want to change it
to something like this, 123 and second number 123. And three dots and
three dots as well. What happens now? Anyway, it said for three dots you can
have this character, but I just use two
dots because I don't want to go inside that A. Anyway, I just
continue to lessons, we might reach them
in another lessons. So first numbers
123 and three dots. Second number 1232 dots
and these characters. So imagine I use
it in ten plays, 15 plays, 100 play. Should I go change every
one of them? Of course not. If I add this or any
other thing after that, all places that I use change. Now you can see
first numbers 123. Even if I run my app, you can see inside the app, they all are changed. I use it in 100
different places, All of them change all at once. Because I change
them in one place. Even if I want to change this plus two, what happens now? Come back, you see this ad. If I have two
language in my app, I can write the Arabic word
for the ad in that language. If my app changes the
language to Arabic, the user can see this ad in Arabic language or
any other language. Okay, let's change it back. A long story short, even if you have one
language, it's better. It's more better to use
the string XML file. You can organize your text. We continue with our
buttons in next video.
20. Day 3: Buttons Properties : Properties four buttons. Now, we have these four buttons and we would like to
make them better. What should we do? We
have this linear layout. Okay. Press. We have gravity, gravity
versus layout gravity. Gravity arranges the content inside the view
means for object. Layout gravity arranges
the object views position outside of itself means
regards to its patent. Let's see the difference of some of values in this picture. Also, there are other
values as well. But just see the
difference here. The blue boxes are text field
inside a linear layout. Let me see. With gravity, we have center left Android. With layout gravity, we
have center left android, by its patent, not by itself. Notes for gravity versus
layout gravity, gravity, wrap content and gravity
are meaningless together. Gravity doesn't work well
on a relative layout, but can be useful
with a linear layout. Layout gravity. Layout gravity only works in linear layout and frame layout. Match parent and layout gravity
are meaningless together. Everything with layout under
line defines something that affects the elements
outside. Please be careful. Everything layout
underline defines something that affects
the elements outside. I think we should make it
more bigger and bolder. It can be center and all
the button or center now. So we learn how to use gravity. Where can we use gravity. Can we use it in other places? Let me try. Control C. I copy all the line. I have the second value, and I press Control
and gravity center. What happened to second value? The second number now center. Let's continue. I have
this as well, Control. And I have this in center. What else do we have? I can write instead of center I have my first
number at the end. You can see the hint at the end, or even start, I can
have it at the start. It's the different
value as you can see. Anyway, let's continue
to this linear layout. I have this in match patent. What if I give it rap content. I give the gravity to it
and I said B at the center. But if I say rap content, it is center, but it doesn't
have any more space. You know, linear layout
now is wrap content. So it's the size of its content and the
content is center. But at the left and the right, there's no more space for
it to be anywhere else. But if you say match pattern. Now you have the
space left and right. Now if you want to be center, you have the space to move
or if you want to say n you have the space
to go to the end, but wrap content, there's no difference between start or the center when
you wrap content. Why? Because no space is here. Anyway, And the center. Long story short gravity
is for the inside. For example, you
can see the hint. The team that inside changed
its location, not outside. And in the linear layout, the teams that are
inside the linear layout are changed their position,
not something outside. The whole linear layout
doesn't, doesn't move. But the things inside linear
layout move with gravity. So we can understand how the
gravity affects our objects, our all object and
get on our screen. I have one more
object to show you. I have this BTN ad, for example, inter G since they are already centered,
I put start. So you can see the
plus at the start now. Let me delete this. Anyway. Okay. Let's layout wait. You weight 0.25 one
quarter, it's from one. If you write just a five
instead of this, half, it's deviated to one, how you infer your
two digit number, it equals percent it's percent. It's 25%, 25% to this, 25% to this, and 25% to
this and 25% to this. Now, all four buttons
have 25% for them. Let's make it more beautiful. What should we do?
We add margin. Okay. Okay, eight D P is good. If we say one D P, something like this,
if we say 20 DP, something like this, eight is good something like this. Nine. It's good, but how
about if our project became bigger and we have more margins and
other dimensions. What should we do then? Like string, as
you can remember, we have this string here. These we also talk about
other languages as well. We have for dimensions. And we should put these
numbers and values in there. In value cli li, new value resources file. Okay. Diamonds is good and say. Okay. Okay. In this file, I need to have a de men name what should we call it. Ten margin and
let's close it and say or let's say nine DP as we write
now let's use it. We have the nine here. Control space, we
have button margin. You can see at sign diamond button margin
has the same value. I put my mouse on it nine DP. If I change it to 11, you can see I have 11 DP. For any other value. Now I have. Because we define this, you can also use it in
here for text input. But I name it I name but margin. Let me change the name. Let's call it normal margin now. Change it to normal
margin and copy this. I have this layout margin. I want this be normal
margin as well. Since I didn't put the same
type for my first text, I just use it in here. Let's have this margin for
other buttons as well. Control C. Now, Control and control, sorry, Control and control. Just like this, it's beautiful. Okay. You can use this margin
with other things. You just press
control C and copy this for this text input field, you also have margin. Property margin or
comments like ID. Many of these
objects has margin. As you can see, there's
the difference. Control, paste it again. Look at the right This
is the difference. Let me give the upper
one not this one. This already has the margin. I want to give it to this. For example, control,
I give one to this. I press control and
paste it again. Look at the difference control this change because the margin. How does it have seven D P? And as I say, if I change
the seven DP in here, all places that are used are
changed at the same time. Okay. And I only change
it in one place. Okay. We can run the app and
see what does it look like, but you can't do it yourself. And an extra tip. I just run the app for
myself to see what happens. It gives me an error. And I choosing this APA tty one. I change it to this
API ty four and it seems to fix the error and
I don't have any problem. I can run as you can see. So before you get worried
and do anything else, check these basic things. For example, your API
level or the other things, or maybe we rebuilt, you can fix the problem. Anyway, see you in
the next video. Okay.
21. Day 3: Quiz: D three quiz questions. Question one, what are the
different types of buttons? What are the different types
of buttons? Question two. What are the usages of
attribute Android ID. What are the usages of
attribute Android ID? You can pause the video
and answer the question. Then resume the video
and continue to watch. Okay. Question three. What does Android
orientation attribute do in linear layout, sorry. What does Android
orientation attribute do in linear layout? Okay. Question four. What is the difference between gravity and layout gravity? What is the difference between Gravity and layout gravity. Okay.
22. Day 4: Day3 Quiz Answered: Day three quiz. Answers. Let's see what do we do. What are the different
types of buttons? We have text button. We have outline button. Tugalt and contain button. We have these four
kind of buttons. Question two. What are the usages of
attribute Android ID. It is an identifier and is used to access
an object later. For example, to define another
object position related to that object or in the code to change or
modify the object. You can pause the video and read the answers by yourself and compare them with
your own answer? Question three? What does Android orientation attribute
do in linear layout? It defines the direction of the objects inside
a linear layout. Horizontal for a row
vertical for a column. The default is horizontal. Question number four. What is the difference between gravity and layout gravity? Gravity, set the content
inside the object. Layout gravity, set
the objects position outside of itself in
regard to its patent.
23. Day 4: Result Section: Results section. We need a result part for the
result of our calculator. Let's close all of this. I lose all of this. Now I have this
after linear layout. After this linear layout, I want text control space. I have wrap content selected. I just press in and
in control space, in. We still have this
red thing because we should say where this
thing we want to be. Where should it be shown. To bottom of layout contrate to bottom to bottom of patent. I just press inter when I
selected and I write start and start to start off and pent I have no error, but it said you must close. I write slash and and
you add this no error. We need a text as well. Let's write text and
the text is common between the teams that are
visible and can take text. I can show you the text. We have warning
because it's better be inside as you
remember, strings. Press and press inter at the same time to
see what should we do? We can click on the light ball. You can see click or press
in Extract string resource. We have let's put it at Arabic
as well and resource name. We add ST before this name. You remember Arabic
we added press this Ken you have aTR result in here. We have this Arabic in here. What do we have until now, we close this I use this hand. We have this in here. If you want to see it better,
you should unselected. You can see it's selected now. We click anywhere else. You unselected and you
can see result in here. We have this. Let's
Let's write more margin. And inter and control space, we give it normal margin. The margin is for some spaces, a little space from the edges. Now, it looks great. Let's continue in
the next video.
24. Day 4: Result Section Part 2: Result section part two. I need a line. I add layout width, as you can see, it's required. I give it match parent, and of course, height. As you can see,
it's also required. I give it two D P I write
an Slash to close this up. As you can see, we have
this line now in here, but I don't want it there. I want it in top of my result. So first, we give this text the D. T X t result label. As you can see, we have this
red line under the view. It said, you should
specify where you want to see this view
unless we show it on the top. I say, Okay, I'll specify
where you sh show this to me. Bottom to top of
top of t x result. We just give the ID T x result that we
just give the ID. What just happened? We have this down here now, as you can see, We also
should give it background. So we write back ground,
background, what color? I think the like
is good. The like. And now we have
this line. No more. So you can see As
I want you to see, I give it, for example, 12 DP. You see this is black lie. Okay I'll give it I'll change
it back to two to two DP. Since we don't have a line
in and with the studio. We create view and we
give this height and w and we give this
view background. For example, the lag because
we want the lack line, and whatever height we give it, we have line with
that thickness. You see, I just change
it to 11 12 DP and you can see thicker line
as easy as that. If I give this wit, for example, five DP and give
this match patent. You have line like this, two DP again and match patent. I'll change it back. Let's have some padding
for this text view, press in there and in here. You can say Android and then say padding or just say padding. We have this normal
margin as you can see, but I think I should
specify something else for the padding. No. I open values. Let's see. We should create
something in here. Control C in this
line and press press inter Control V. I said
you can't have duplicated. I say, Okay, let me
just have padding. I have normal padding
and I want to have a little different
between this, I give it eight. Let's close this. And for the padding, I'll give Normal not merging,
normal padding. Now we minimize this like this. As you can see, padding
is for the inside. If you don't have this padding, let me zoom it more. I'll cut it. You don't
have this internal space. Padding is for this inside, internal. Let me show you bet. For this part for
the internal side, you have this padding. If you don't have it, you
don't have those space. And if you don't
have this margin, margin for this outside. It's look like this. If you don't have padding, padding is for the inside, if you don't have margin
margin for the outside. If you change the values for the padding inside spaces
became less and or more, and for the margin, outside space became
less and more. Less or more. What
else do we have? For example, we
have this padding, and also we can specify this
padding for top or bottom. Bottom, I think
it's better sample. We have this for the bottom. For the bottom, we
have this like this, remove bottom
padding, like this, back button padding, like this, and only have the padding, it's look like this.
What else do we have? Bottom start top and
many other things. But most of the time, we use the padding. We use the margin, not specification for
the bottom or the top. And But but you can
have those things. And I think we reach them in the future
courses as I plant. I'll give you one more example. You see this margin. Let's change this
margin like padding for not bottom not
to for a start. You have the margin
only for a start, only on the left side. And if you remove this, you have it all around. Enough of this, let's copy this control C and case in here. You said you have
duplicated names. I remove this label. It's okay now to start off no end to end of what to
end of this result label. Why do I do that? Because I want this to say the
result will be here. And I want this one to
show the actual result. So this one for knowing where is the result and this one
to showing the result. Let's connect the right side of this to here like this. Let me change the wit. We have wrap content, but I don't want
this much little. Let me have match parent. But we have one
problem as we can see. It's on the other text view. If I change it again
to wrap content, as you can see, it's too small. So neither of them helped me, and I want this from here
end of this text to here. But what should I do? We can write zero DP
like this zero dP. What just happened.
It's not too big. It's not too small. It's just the way I want
this zero DP for the w. When you can use it, you can use it when your
left and right connected. If for example, your
right isn't connected, you can't use this zero DP. For example, let me
remove this line. It can't work anymore because your right doesn't
connect to this right. If I put it back, it's work now. I hope my tips and tricks
can help you because I try to give you many
tips and tricks as I can. Just one more thing, we should say gave, Why? Because the text, as you
can see, it's on the left. I want it in center. Now let's run the app. We waiting. Our app is running, and it is great. Let's continue this
on the next video.
25. Day 4: Tools: Tools. As you know, it's a calculator. I want to enter about ten or 20 gets
for this result part. I go down and as you can see, I have text in here. I'll simply change it to zero, one, two, three,
four, five, 6789. Or maybe 20 digits. It's better and more realistic. 20 digits is enough. Let's see what's the outcome? What is the final result? It is our final result. It's look like this if
you enter 20 digits. Let's run the application
by clicking run app. Our app is run now. I minimize this and as you
can see, it's look like this. Let's stop it. As you can see, the outcome
shows me this number on the device and on the final
result on user's device, user can see these
numbers as well. What I want to do, I want to change this
Android to tools. As you can see, I have this now, and that underline
yellow underline is gone because it doesn't recommend me to put it on the string file. So let me run the up again. What happened now, we don't
have this number in here. But as you can see, let me stop the app. You have it in here. So you as a programmer can see, what is the out come result? What does it look like?
It's look like this. But if you create
your final app, The user don't have
these numbers. User have something like
this and empty space. It's really helpful for me as a designer to see
what does it look like each part if I have to put them a few
string a few data. But of course, we don't want to have the data in
our outcoming app. It's just test and for helping us to better
design to easier design. Also, if I stop it
again and minimize, as you can see, if I remove
it, nothing has changed. It's still here,
it's the same size. Everything is the same. But we only put this in here
to see what will happen. Now, we can know how
much space do we need? For example, if 20
digits doesn't fit, we can understand it now. One more thing since we're
already here, let me see. We have this. What happens
if we remove this line? If we remove it, we have a error everywhere
we call tools, and it you can import namespace, so we can understand you use tools and what do
you mean by tools? We can import namespace
or press all inter. Simply click on that
and import tools. Everything's now. As I say, if we want
to use anything, we should declare that thing. For example, we want to use the Ts on the tools namespace. So first, we should
use tools namespace. After that, we can use tools. Or Maybe Android, we have Android Android
Android in here, and we have Android
namespace in here. If we remove it, it said, I don't know Android. What is Android. You should import
namespace for Android. Otherwise, you have error, so import, and it fix. Long story short, we
use these keywords, and we should do something. Andrew Desio knows what
are these keywords? We use namespaces for that.
26. Day 4: Variables Part 1: Variables, part one,
variables in courtly. Variable is a continuer
to assort data values, how to define you write R, your variable name equals value or your variable
lanes equal value, and R or kwar R, the value of variable can
be changed or modified. For example, first
name equals or. First name equals john. The variable name, first
name change to John. The value of a the value of
variable cannot be changed. If you are sure that the value won't be modified in the
future, use this word. L H equals 25. If we give a 45 in the next line or
anywhere else, we have error. Variable name rules
can contains digits, underscores and dollar signs. Should start with a letter, dollar sign or underline,
case sensitive. My age and age are
different variables. You see the A, capital
A or a small A. They are make the difference. Should start with a
lower case letter, and it cannot
contain white space. Reserve words, like
cutlin K words, such as R, or a string
cannot be used as names. What does it look like? It's completed. Our
design is completed. Now, it's look like this. I run the project,
and as you can see, if I write something
and press a button, nothing happens
and another number the button and nothing happens. We need to write
code to say if we click on this button,
what should happen? We open the project
and on the project, we open main activity. On the main activity, we have this part
and press inter. We write our code
for the activity. I want to find this
button this button, PTN at, I want to find PTN
at on my cut lin code. I write find view by ID. What do you want to find? I want to find Malt
material button is here. What is it ID? I want to find it by the ID. First, I want to
look at resources. You see there's resources fer. I write R I want the ID, O, R that ID ID. What is ID? You see
all the IDs in here. I want PTN at. Look at here, PTN
at. This is my ID. So I say PTN at. I just want to be sure so I can press control and click on it. It takes me to that
button with that ID. Once more, press control,
click on the ID. This is what we refer to. I hope I say all of this clearly because I want sure you
know this very well. You find it. What should I do? I put a dot. What should we do? Set on click listener. And as you can see, we have
two set unclick listener. This and this. I want this one. In inter, you see all objects that you have in
here have unclick listener. Even these boxes
for inter in text, these things have unclick
listener as the. Anyway, It's really simple. We say sit on click
listener. What does it mean? It means, what
should happens if we click on this button on
this thing, anything. What should happens? It should happens like this. Take this number.
Take this number. Add these two together and
show these two inside this. This is what we need to do. Take this number,
take this number, add these two, and
show them in here. Let's do this. We want to
take this. What is this? It's text input dit text with the name of
EDT first value. What I want to do, I
want to find view by ID. Again, find view
by ID. What is it? It's dit, dit with Big E dit dit text
or to be specified. There's no difference,
but to be specified, text input edit text. Text input edit text. And it said you should import text input
edit text. You see? If you don't have
this, s you should import this Class I imported. So it's fine. Let's
clod this again. Okay. Edit text or text in both edit text
are both edit text. I just want to show you there's no difference and
you can use both. What's its ID? R resource dot, dot what dot ID. I want the ID, dot,
then what EDT, You can understand
now why did we write edit texts with EDT or texts or buttons with
something before them. For example, we write for botms Bt N because
we find them easily. Anyway, DT first value,
and it's the same. You can easily press
control and click on it. You see you refer to what. What I want, I want the
value inside that it takes. How can I find it dot
what I want text. I want the text inside
that edit text. So let me just click here Control C and go to the
next line, Control V. I have two of these now, but not the first value. I want for the second
for the second. I have edits. First, edit second. It's really common. You just copy a line and paste
it somewhere else, so I don't have to write
all of these things. Just a part that changes. Now, what, as we say, we want to add this and
put them onto this part. I need a place to
store the data value. I need a place to
a sore my value. Many times that you need some
place to restore your text, your values, your number. This is the time when
we use variables. Particular and variable, use
R. R is short for variable. What should we call
this variable? We call it H or family family or last name family name pi n. What do you want
to store in this? I want to store on this. Let me just remove
this and just name. What type of data do you
want to store in this? I want to a store text
inside this variable. What is text, we know it as a string. You
see the problem. You should write Big S.
If you don't write Big S, you have the error. It's case sensitive
inside this programming. Now, it's finished. Later on, you can put some value on it. For example, my name equals, you should put a
string on this saw. You write, for example, Jack. If you try to put
number on this, for example, 23,
you have error, Y? Because you can't put
number inside the string. See you can put this 23 like
text inside that variable, but not like a number. So I press shift and
this button next to the inter and go here
and do this again. This is a text. It's okay to put a text inside the string,
but not a number. Let's me back my name. One more tip, you can put this on the up here when
you declare this string. You don't need to use it here. You can easily give this the value when you
declare the value able. One more thing, O thing. It said, this is extra.
What does that mean? It means if you click
here and click remove. It removes the string. Why? Because the cut ln understand you put a
string on it and it gives the string type to this
name variable by default, you don't have to
say what is it. But sometimes you
want to be specific. About the data type. Then on those times, you can say what data
type you want exactly. Even on this situation, it gives my name string type. So if I say, I have my name, put
a number on this. It says, no, no, no, no, no. We Consider this as string. So you can't put inside
this string, a number. Also, if you consider
this as a text is okay, but not a string. Not a string. We talk about number a lot. Let me have a number as well. He equal Let me see. I have, H equals equals what? 11. Also you can have
your data type. What is it int for integer? It said you have an error y
because you should put big. And also it said, you see, You can remove it. What if not is okay. Integer is like one, two, three, four, five. You don't have smaller
than one on them. For example, 1.5, you
don't have 1.5 on this. For example, 111.4. It gives you error. What's the problem? You can use double four. The decimal numbers, you can't have this
number inside and in. And as you can see,
you can understand why sometimes we should declare
what is our number. Because maybe we don't want decimals and we only want int. In those times, we
declare what I want. What do we want.
Let me remove it. And one more thing, if I say
H is equal 23, it's okay. I have repeat this many
times and change it a lot. But instead of R, I say, I can change it. Just give the value to this
variable one time, not more. This is the difference
between and. The difference between
R and it's only this. I see on the next video,
27. Day 4: Variables Part 2: Variables, art two. Let me select all of
these ED t first input. The data type is a string
and it equals two some data. And since as we are in cut, we don't have you this string. It detects what the data type is unless we want
to and we need to. Let me just remove
this and copy this. Put this in here. This text is going inside
this and this is our text. Our data goes to this variable. Let me close this.
Before I forgot, I should write that to a string. Why? Because I want to
be sure the string of that text goes to my
edit first input. Many times many other places. We should be specify to be sure the right data type of
data goes somewhere. Just to be sure and don't
have any error and problem. So I should copy this to here, and I don't have first, I have second copy and
paste sorry paste. It second value and
that string as well. What does that tw string does? That twe string goes
here and take the string inside of each of these and
put it inside my variable. One more thing. You see, we have to a string. We don't have int, even with big o, we don't
have to int to a string. Now, let's have our
third variable. EDT result is equals to to what. Copy this, paste
it in here, los. Copy this and paste it in here. This plus this goes
to result. Why? Because we write code
for PTN t. Now what? Now, we want this DT result, put this inside this
bottom. What is it? This is TC result. Again, I just copy this
and paste it in here. Change this part
to t x t result. Don't remember, it's not
text input, dit text. It's text view with
big T. Text view. You see, this is text view. Press control, click on this. This is text result, and it's a text view. So what's next? Next is do do what text? What should we put
inside the text? E T result. What is DT result? The result that we store, let's put it inside that text. Okay, let me run the app
and see the problem. So we can learn so
many other things. Just to be sure, be careful about capital and lower letters. It's really important. Big and small letters are difference ins cooling.
Let's run the app. So now, if I put
three and put four, I should have three
and four equals seven. Let's add them. You see the number 37, T four, it said
it's equals 37 y. I tell you why. It
consider them as text and put three and
four side by side. Not the numbers, not
like numbers, like text. First three, then four, put them together, three, four. Because you tell the
computer do this. Anyway, as I say, these are text now. So what should I do? This text, this text. Even we do to a string, because they are text,
what should we do? So now, what should we do? We should say we want
this to be integer. So D to what you
see to a string, to wide, too long to int. I want to int. The second one, you see it said, you have in here a string here. Solve the problem to
what to integain. Our problem solved, and we
have this as a integer. You see, dit result integer. Our problem solved, but wait, we have another problem. This text gets a sing. But we have this int. What should we do to
solve this problem? Let me solve this
because this text, take text, take a string. D to a string our int, goes to the string, be a string and then
goes inside the result. L et's review. We want integer, dot to in, we want a
ring, dot to a ring. Now let's run the ap again. I put three inside this, I put four inside this. Last time we see 34 because
program put them together. Let's press this button
and then we have seven. Three plus four equals seven because it's number
now. You see? We also have these warnings.
What does they say? They say, you can
change it to al, y because you only put the data once inside
this variable. So you can use. It's optional, no
problem with R, but you can use. I change them, and you can see the three
warning becomes one. I solve this three. I
see on the next video,
28. Day 4: Functions: Functions. A function
also known as a method, a segment of code that
is executed only when it is invoked or called
functions can receive data, referred to as parameters. They are used to execute
specific tasks or actions. Create a function. We use fun keyword, as you can see, and as you
can see in the example, call a function to
call a function, we write that function name followed by two
parentheses like this. Okay. Back to our programming. We write some simple code to take this number and this number when we
press this plus button, add them and put
them into this part. In our text view. Just this few line of code. Now, the problem. It's not
good that we write like this at main class and we
write all of this together. If our program became
a little bigger, all the codes inside inside of each other and in one place, we easily can get lost
inside all of those codes and our program might Mostly, mostly have lots of problems and errors because we can't
find what's what. We get lost. Before I forgot, we have this uncreate function. We write our codes inside
this uncreate part. When our activity created,
these things happens. You can see even this create is a function with this F U N word, you can see this is a function. Let's create a function. I press in in here. I write f because I want to create a function function,
my function name. In it, listeners. This is my function name
and open and close, and this is my function. Now, what should I
do? I select all of these to the
end and control X, cut them, Control, paste them
29. Day 4: Errors And LogCat: Errors, and log cat. Okay Let's continue.
Minimize this. Let's run the app again. This is our app. I
insert a number here. I put this thing blank, and I press this class
button. What just happened? My app closed because an error, because I didn't put any
number in my second text box. You see this logcat. Click on this. You
have the logcat. Make this a little bigger. And you can see this error here. You see just at the bottom. I have this fatal exception. There here. What is it? This is my error. I have another descriptions, but main and the most
important thing, this line for this
input string empty. Why? Because in this code, I want to make this
empty string to integer. I don't have a zero. I have empty string. This makes the error. Even it said, you
have this error on where on main
activity, Cutlne 26. Line 26 is here, line 26. So you can find out where
is your error exactly. Also, you can see in
the Android classes, for example, in Java for the integer things
and other things. But because we don't want
to do anything with those, we just work with
our own code and we fix our own problem in line 26. What problem, this problem? Input string is
empty. Extra tip. You see this package
mine y package mine, because I just want to
see my own package. I don't want to
see other things. You can press control space
to see the suggestion. Let's press control space
to see other suggestions. We don't need any
other things yet. You can see all of them are here packages
or other things. We don't need them yet. Only thing we need to
see our own package. Package mine. Why? Because I just want this package name to see
what happened with this. If I don't write this, I might see all the
other things because this emulator have
other things inside. But I don't need those things. I just want my own package. And before I forgot, let's press this to
add to favor it. Maybe next time we need it. Anyway, now we understand
what has just happened. Let's minimize this and go here. I give you another example. Press inter in here. You see, I have,
for example, what? Number one equals what? Equals, for example, 34. This is string. And when I want to convert this string to
a number, it's okay. But if it's empty, I have error. If it's zero, it's okay if
it's empty, I have error. So I have, for example,
23? It's okay. Even if I put a string
after that, I have error. Only number. I can convert a
string to number, only if I have number. Okay. Now we understand, what is the problem? Let's cling this and let's
continue into next video.
30. Day 4: If Else: E, you have if like this e
condition and some code. If the condition is
true, your code runs, and you have e, if condition, this code, and if not, the condition
isn't true else. This code. For example, you have this e for this
value age equals 24. If age less than 30, you print less than 30. I have less than 30, this part runs,
print 30 or more, but I don't have less
than 30, this part runs. My output is less than 30. Back to coding. So
we have a problem. Let's see our app.
We want to check if this part has number
and this part has number, then we run our code. So let's see if these
are empty or not. Right here, before run our code, we write we need a condition. If what? If text utils, we need something
from text utils. Text utils is for Android. We need what? We need is empty because
we want to check the string is empty
or not, is empty. What is empty. Our EDT first input is t
or not. Let's check it. Okay Let's go with another way. First, we remove this
and then remove this. This is it takes
now this variable. You see, it looked
like this just right. Variable variable,
what, for example, T is what dit dit text equals why? Because we can create variable other than
string or numbers. We can create variable put the type of an
object like edit text, and we simply put this
inside that copy and paste. We put this inside
that and of course, text input edit text. It's okay. You remember,
we have no errors. We can write edit text
or text input edit text. Let's remove this. As I say, we write the edit
text inside the variable. Like this and we want to
use the own text self. Of course, we should write
dot dot what do text. Because we want to check
the text is empty or not. Let me just open and close
this and press in there. I just continue this
in the next video, because I want to show you different things
in the next video. I just want to separate this
31. Day 4: EditText Error Property: It text error property.
Let's continue. Okay, EDT first input. We have this dit first input. What just happened?
This dity first input, the text is empty. So what should we do? You do something about
this because it's empty. Dot error. It's a great property error. What should we show inside
the error equals, get text. Get text. G text what resource dot inside
the resource string. Look at the strings,
and then what? STR SCR. I have many SCRs, but I don't have
SCR for this error. What should I do? I
write the perfect name. In input. I first Input, please I think it's good or in first interfirs. Input. Please error. It's optional. We can write anything
like this. Then what? Then we should click
on here and click on this Light pub pulp and create a string value
resource for this. Okay Let's create
this string value. It. What is your value? Please first I think number number just like that. And the check for
the Arabic as well. I click. Now the error is
gone because I have this. If I open this project, go to the strings. I have string and
string Arabic, string. SCR infirst input, please error. Please inter first number. Inside the Arabic,
please in first number. You see, No difference. Why? Because I should
translate it myself. Let Let's hide it and
lose this and lose this. Long story short. If it's empty, give me some
error, Whatr, this text. Let's write else. Now, we understand what
is it, but how else? This condition isn't true because we put some
text inside this. So it runs the else. We write else. Inside else, I want to
check second input. So not the first input. This time, second input. So I just copy the whole
thing control C. Click here. Control. Sorry, I need space. If it's not empty, check again. E is empty, it first,
not the first. Now it's time for guess what. It, Control space, it
second value, text. If second value, text
is empty, so do what. Is it the first, not
the first. Be careful. You copy, but you should
change the part you want. If not, you don't give error, you take error from the app. The app isn't work
just like you want. The program doesn't
give you error, but the app doesn't
work as you expect. So be careful. Second value. Finally, I change
this verse to take. Second, and it says, Well, what should we do? Create a string value resource. I can use this light
bulb or click in here and it says,
what is your value? I check the Arabic as well. Please in second number I press this grades, again, let me check. Please inter second number. That is first number,
is second number. Please inter first number, please inter second number. As I say, we should translate Arabic or any other language. I just write Arabic
as an example. Finally, L. What
else do This part, if the first input have something and the
second input have something, has something, Now
it's time to add them and put them put the
result inside the text view. Oh, I have this error. Let me fix this dot
dot what two string. Then two in. And again, dot to a string, then two in because
our in needs a string. Let's run this up.
Click in here and wait. Okay minimize this and zoom, this, and I don't
inter anything. I just make this a little
bigger and click here. I have this error.
I click on this. Please inter first number. Oh. So this tells me what should I do
to fix this problem. It shows me this
string first input. Okay, 22. Plus, another error. What is another error? Please inter second
number. Okay. You see it catches me
inside the second. Now, what should I
do? Inter a number 22 plus one equals 23. Let's press plus
and crashes. Why? Because we have error. What is the error?
Let's open this cat. Open L cat. I have this
and I'm going up up. What does it say? It say for the input string,
number format exception. For what for this input string? What is the input
string that you can't exchange it to the number. This is our input string. This isn't a number. It's text. Why? You see, this is our text, and it can't convert
it to number. Before I forgot, you see this, you see another thing in here. But I don't want
these other things. I can simply write. Okay. I want to write level. Let me just press control space. You see? Control space. It shows me this guide. I want to write level. Age is message level.
This is level. Inter level. Level, what I want error. Or I can press control space. It shows me. You
have level of this, this, this, this,
this, and this. I want error, instead
of typing that. So what just happened, Level error, and space
and level error. What does it show? You see? Just the errors. Nothing else, just the errors. Because I want to
find all the errors. I make it simple. Especially when you
have lots of messages and you just a specific
thing. You see? I say package mine because I want just my package package, and I say level error
because I just want the error of my own package. And if you have lots of error, you can right click
click, clear. Li cat, it clears all
these and you run the app again and exactly do that thing
to show the error. So you don't see
error from 5 minutes, 10 minutes or 1 hour ago. Just from now, I can
clear it like this click, clear and go to the app, do the thing and have error exactly for
this part of time. Another thing, as I say, you have this line 33. Why? Because you have
this error in line 33. We don't do anything
with the Java codes. We have this part. We work with this part, line 33. What is line 33? This part. We have error in this. Even
if I were here, I'm here now. If I click in this, it takes me to the main
activity cut line 33, the exact location of my error. We know the reason. We know the line. What is the problem? The problem is we convert this edity first
input to a string. What is this edit first input? This is press control and click. This is text input edit text. You convert this to a string and then try to
convert it to the number. So You can't convert this
this a text to the number. You can't convert it y because it's not a value,
it's an object. So, I understand
what is my problem? I should first say, I want the text of
this DT first input. Then make that text string, then make that string an int. So this is the same. First, take the text, and then make it a string, and then make that
string an integer. I hope you understand. This variable is an edit
text. This is the problem. One more thing, I
can use this with Big i integer dot value of value of this string
value of string. Let me just cut this and put it inside this
and I don't need this like this I make this string as
integer, like this. It's equal. Let me just crest
inter in here so you can see this is equal of this. Okay. I can even press inter in here, so I have it in next line. I can write to directly or I can use Android
method to do this. Okay. Let's run the app. But first, as I say, you see right click
Clear like ca. You clear it like this. And now if you have
another error, you can see that. Let's run the app. I
have first number. I don't put anything. Click here, I say,
please interfer number. If I put any number, the error will be gone. This error property
is really good. It's for text input. This edit text. I write 22. It's gone, the error is gone, and I pressed plus, I had another error. Why? Because it's empty. I write one. It's gone. I press
this plus pattern and I have this 23 in here. 22 plus one equals 23.
32. Day 4: Minus: Minus. We just use
this four PLS. Now it's sim four minus. From here, find V y ID. Let's copy this.
Control C, er control. Now, I have copy
the previous codes, exactly the previous codes. First thing we change PTN, no Pt n minus. You see this part,
you have the plus. You don't need the plus, you need the minus. It's really simple,
It's really easy. Let's start the
app, run the app, minimize this and write seven minus three and press this minus equals 47 minus
three equals four. If you press this
plus equals ten, but if you minus equals four. As easy as this, you write the minus code. I think you might say, why don't we repeat
many of these codes, for example, This edited first input and this
edited first input, we have many of these things. Why we repeat
repeat these codes? Why we use thes many times? Yes, of course, we
make our code better, but in the future lessons. For now, I just simply
copy this code, change this name and
change this character and see how easy can you write
code for next button, I see you in the next videos, and I think it's enough
for today. Yes, maybe. I see you in the next day.
33. Day 4: Quiz: Day four, quiz. Question number one. How can we create
a line in Android? You can write it down
and then answer it. How can we create
a line in Android? Question number two, what is the difference between
margin and adding? What is the difference
between margin and padding? Question number three. What is the use of the
following feature? Tools text. What is the use of the
following feature? Tools text. Question number four, what
is the use of function? What is the use of
function? That's it. You can write it
down all of this and then When you answer, check the first video
in the next day for compare to your own answers.
34. Day 5: Day4QuizAnswer: The four is answers. Question number one, how
can we create a line in Android with a field view
and limited width or height? As you remember,
we, for example, give 23dp in width or height, and we can have a line. Question number two, what is the difference between
margin and padding? Padding, for innerspace,
margin, or outer space. You need space
around, for example, your button, use margin. You need a space for inside. You need to use padding.
Question number three. What is the use of the
following feature, tools test to the PLA, the content only to the designer and not in the output version. For example, we need to see if we put 20 digits
side by side, how much space does it take? But we don't want
to 20 digits be on our output or even
in our emulator, only when we're
coding and designing. In those times, we
use tools text. Question number four, what
is the use of function? Grouping code with the same god. For example, I write a
bunch of code for adding. I write a bunch of
code for multiply. I write a bunch of code
for anything else. I use function for
grouping them. And as I say, when you
have figure program, for example, you have
thousands of line of coding. So you use many functions. So you can find the group
of code that you need to edit or fix the
errors or anything else. And one more thing, I think I say, if
not, I say it now. When you use a bunch of code many times it's better
to use function. For example, Imagine you need to save something before
you close the app. You don't write that
saving code many times. You write that code one time in a function with the proper name, and whenever you
want to exit the app and save the some
status or something. Use that function. I hope you enjoy and
learn all of these. If not, please review day four. If you learn,
welcome to day five. Let's learn many other
things together.
35. Day 5: Review What We Learn So Far And Some Tip: Review and Tips. Let's review. We create a calculator. I just want to see the design of this and yes, just like this. This is our calculator. Where where we create our
calculator and we say the layout contains
the things that you see on the resources,
on the layout. O. This activity main contains the things
that we can see. I mean this page or this
view. I should say. We call these pages activity, and in the first lesson, we create this project
from zero under Catlin, under our project name, we project package name. We create this main activity. For this main activity,
we create a layout. We talk about the
activities that each activity has a layout. This part has the code, this part has the design. We understand that this XML contains our layout and we talk about how we can see the design mode split
and or just code. We talk about constraint layout, and also linear layout. That looks like a line y. Be the objects inside linear
layout, They are oriented. They put together, they
shows together like a line vertical or horizontal. After that, we create these two boxes for input in
texts, and these buttons. We talk about these materials
and why we materials. We say the own Google, the Google itself
introduce material. Because material designs
makes up in some ways better. As you remember, we
create these buttons and since we want them
line up together, we create this linear layout
and we make it horizontal. And also we talk about
the weight because we want our side
to be by weight. We also create a
line by this view, we create a line. We simply give this
background and a height so we can have
the line in this place. We mentioned that we have this
background for this view. And we also say we have this background for
all the other objects. At least most of them. For example, we
can just copy this and pre inter paste
in here. You see. Now we have this background
for this text view like this. There are other properties like this background,
like padding, like this set hate ID
that are common between most of the objects
because most of these objects has
these properties. And since you can understand
how you use this ID, you can use it in
the other objects. We can call them common
properties or regular properties. We also create
this text view and this text view because we
want to see the final result. I have a few rules. I recommend this to the people. I put ID first. For example, wit
and height next, and bottom up sort
of at the last. I recommend you write like this. It's easier to find things. It makes many things easier. And I do this in
many other ways. You can see ID first and
then Witt and height. And When I want to find the ID. I always know, I
put the ID first. It's really helpful. Or the other thing, you see, I have these texts. I have this text first control. I have this text. Let's see on the main string. You see all of these
has this STR, SCR SCR. Why? Because it's my principle. It's my rule. It's easier to know,
it's a string. And it's easier to
find when I want to search for this
you don't have to, but these rules
makes things better. And also, we have this layout, as I say, we have this values,
diamonds, and strings. This string is default language, and we also add an
Arabic language. You can add any other language or you can have different
default language. We put it English default. Our default language,
put it in English. I just copy these three lines, paste them into Gu translate and copy and paste the results
inside these three lines. Why? Because I want to
translate the others. This is Arabic. It
shouldn't be English. Let's close this, let's close. One external note, you can even have click for these
for this or even these. All of these can have click. But as you remember, we just put for these buttons. Most of the time we use
it for the buttons, but you can use it
for the other things. As you can remember,
for that clic. We should define that button, find it, and define
that k listen. For finding it, we use find
V Y ID and find that button. My button is material button. I should define what is my
object that I'm going to find. Where is this? I press
control. Click on this. This is my TN ad. What do we want to do when
we press this button, we want to add this with
this code, you can see, we find out each of them
and add them together with this plus and put them
inside this tit result. I recommend before start typing, before you start typing, think about what you want to do. For example, first, I decide
I want to add these things, then I start coding. And we talk, we must
find each of them, so we use find view by
ID for each of them. First input n, second, and also we check,
are the empty? Is the other one empty? If not, let's run the code. Also we talk about this error. How can we show error? It's enough for the review. Let's start coding and
continue the course.
36. Day 5: Gradle And view binding part 1: Gradel and view
binding part one. Welcome back. Let's
go to the code. Open main activity. You see we have many
fine view by ID. To find the object. I should write all of this. Isn't there any easier
solution that helps us? So I don't have to
write this fine view, fine view by ID every time
and go to find that object. There is an easier way. What use view binding. What is view binding? Vew binding helps you don't you have to write
these fine view by IDs. If I want to say I want
to click on this button, I don't have to write A code and it's makes easier
to find my object. First, gradle. This is gradle part. This file, you see that? This second file with this name. Be careful. There is the same
name just up in here, not that module app, not that project, module app. Let's just open
it. Double click. We open this. What
is this gradle? If I want to use
thems and libraries, first, I should
define them in here. For example, we want to
use view binding, first. But first, we should define it, then we can use it. Where should we do this in Android CDs Android
section. Open it. Let's go down there in
here, inter, inter. Let's write B. I write just a few characters
of these build features, and it gives me all
the things that starts with build F.
But just be careful. If you write, for example, O, You can't find it anymore. You can use android studio hell, but you shouldn't
write anything wrong. Careful and open and close in. We have vi binding, and it's equal to what true. Y because we want to use it. So what happens? What is this light? Sync now, y? Because we change our gradient. We should sink entire project. So I can press this
just like this, press this and sync
now or at the top, you see it says sync now. Why gradle files have changed. So you should syn,
press, and wait. Okay, it's finish
back to our code. Okay, we're going in
top just in here. So what should we do? Let's define a variable. We can use or. We use. What's the difference?
You should know. If it's, we can give it
multi different values, but just one time takes
the value from you. Of course, if you
forgot these things, you should review
earlier videos. So what's the name? Binding. Activity main binding. Is this a important
name or code? Why it's activity main binding? Because My ML is activity main. So I want activity main be bind. Whatever is this thing's name, my binding is with that name. For example, if it's activity about I should write
activity about binding. What's next? Dot inflate Layout inflator. Okay. I have some problem
with this in plate, and it gives me error. So what should you do? I make this simple
solution that I just did. First, I go to this menu. Go to build. Press, clean project. Clean project, press it, wait until it's finished, and then then what file
come all the way down. In validate caches. Why it takes about I think
30 minutes at least for me. And I have to search about some other things
and got confused. After these years
of coding. Even me. So be careful. Check all of these three things. If it can't help you. First time you
invalidate and restart. You check this. Check
this, check this. Clear everything,
invalidate and restart. In the first time, because I forgot it might
because I forgot. You can't be sure.
Might because I forgot. Check these three. I'm not sure which one of
them do the job. And invalidate. It doesn't work anyway. I check at last, I check all of these three. And first, first of all, I restart my system at the end. After reasserting, I
do all of this again. First, I came after reasserting,
rebuilt, sorry. Kian. After Kian, go. And invalidate. And then I think maybe this
can help check these three. Why? Because it
clear everything. Even file system cache. It clears everything and
invalidate and restart. Check, check,
invalidate restart, and then I just rebuilt Then I saw this
where is my error? It's gone finished. Everything is good now. Anyway, I might make this part one a little
shorter because I at least take half an hour
to find out what's wrong. Please take a note of
these three steps. It's really important. Sometimes even professionals, programmers, Make
these mistakes. It's a really simple
mistake. You see? I repeat one. Simple mistake. You and say, Okay, I invalidate, and you forgot, check these and you confused
because error isn't gone. What should I do?
What should I do? I can't find it.
Anyway, let's continue. I hope this, this one
thing helps you a lot because it helps me and many
other people and restart. I'm not sure maybe
restart can help. If it can't help, first restart your
computer, then do this. And remember, sorry, remember, you should connect
to the Internet because it takes
the library again. I almost forgot to tell
you this. It's important. Now, where were we? We activate our binding, and if I press control, you see, I press
control and click. I go to activity main. Press control. Where is it? It's here. I'll
show you one thing. You see this activity main. If I press control, click, come here again. So it's equal this equal
this longest story short. This is my activity main. This is my layer,
but it's binding. So we create a variable That contains this
activity made. Set content view, set our
view to this code from this layout resource
because our activity contains two part one is
this cout code and two. This layer, this view, the thing that
people can see Now, we want to join them together, so we say set content
view for this code. For example, let's add layout new and layout
resource file. Click. What should we call it? Let's say Login, just press. We add it Let's
simply add a button, button and to here and this
and this and this to here. You see you can do this
with the design mode. You see here, design
split code. It's design. Simply open this common button, the drag and drop the
button and just like this connect the dots to the corners. Y we write code, because it's better
because it's more specific and I prefer that. But after the course, it up to you, you can use this. I prefer write those codes. Maybe in the future
in the course, I do the design mode so you can see more of this
and you can decide them. Let's see the split. What do we have?
All of these codes. Now, if I want to
set content view, for example, log in, I can give log in to this and press control and click
for going to log in. Why? Because it's logging? No difference. We can comment this. Do you remember comment?
What is comment? When I comment a code, we don't consider
that as active code. We just write it for ourselves. Andre D Sudo doesn't care what
do you write in that code. You can write whatever you want. Even write stars, peels, all the things you
want, or write. For example, you can
write this line do that. As I say, Andre D Sudio
doesn't execute the comments. Ignore them, like all other
programming languages. So let's run the
up to see what do we have. I run the app. It gives me error. Of course, why? What just happened? You see. You want to run codes and find V Y ID that you don't
have in that log in. Anyway, long story short
comment, and running again. This is what we have. This button, and this is the
login page. Stop the app. I do all of this to show you what does this set
content view does? It sets our layout view. Instead of this, show me
this and Ling a story short, this is what I want to see. Let's continue this
at the next video, so we don't have very
very long videos.
37. Day 5: Gradle And view binding part 2: Gradial and view
binding part two. Where were we? We talk about set content
view and what does it do? Let's delete it. I press
delete on my keyboard. I click. Now it says, I don't have any log in. I change this to activity main. Now let's remove this comment, and we want to
this content view, take the values from this binding that contains
our activity main. Do you remember
activity main binding? We bind our activity main. The first thing is
we cut this control x and inter control V, y? Because we want to
use this inside this. Now, we say, we define this control C and
inside this control V. You set content view from
that binding You should write declaration of your variable before the place
you want to use it. Now, we write that. You see, if it doesn't
open this help. You can, for example, if I click somewhere
else and came back here, it doesn't give me
that help thing. I just press control
space to open this or simply write any
letter for the thing I want, for example, I write R Y, because I want root. Now, instead of doing
all of these things, I can simply write
something like binding. Inside binding PT N. Do you remember why we
write PT N before buttons? Now I have my four button. If I write other
things, for example, just add, I can't find
them this easily. I write PTN before
the button names. Now, I want to find
all of my buttons. I simply write PTN. I have the list of my button. The rules, the structure of
the naming that I told you, There's a very strong reason
for using these rules. It's really important. You can have your own rule, but you should use the rule
all the time every time. I write PTN. So I want my button. PTN. Where are my buttons? You have these four button. And I want my PTN ad. I just go down, down, down inter. PTN ad. Inside that PTN ad,
what do I want? I want set on listener. It's easier then find view
by ID and other thing. Agree, and I write
my code inside here. We write it instead
of all of this code, we simply write binding
and this a PTN ad, instead of all of
these codes, binding. And of course, after
that, set on listener. You might say, why didn't I
show you this in the first, why I bother my myself to
show you this kind of code. Why didn't we just write
the short code instead? Because you should understand
all the way that you can do the things and you can decide
in a certain situation, which way is better. You should learn.
This is fundamental. This is basic. You should learn these things very,
very carefully. Because of that, I tell everything specific and with
very details and examples. So please please learn these things very
carefully and very good. Let me give you another example. Next line, you have. Find view I move it it in here. Okay. Find view by ID. Text input, edit text
and other things. All of these things, I want my Edit first value. Do you remember Edit first value Edit first value. The ID. Is the name of that object. I want this DT first value. What should I do?
Instead of all of these? Let me show you bind D, D. This is very good. E. Why should we write DT? We can use anything, but if we write D t in the
start of our edit text, we simply find them. This is our two edit text, and simply inter This
code is equal to this. All of this became
this simply, easily. As I say, you should
learn both the ways. Very carefully because this is fund the method,
very, very important. Before I forgot, I should
remove this comment as well. This is my method.
This is my function. Okay. Let's write binding and replace all of these things. Let's go. Binding Bind D. What just happened? I said, I don't know any binding.
Where is binding? We don't know binding. Do you know what just happened? We declare our binding. This is our binding, and the use our binding, but with the same name, you see Control C. Exactly, I just copy that. Control V, paste that, but I can't use it in here. The U say I have the
variable, the name binding. You can use the binding,
not before that. Do you remember? I just said if you
declare this binding, you can use before
that declaration. Because of that, We move
this line of code from down here to up y because we just want to
use it next to it. Please, please pay attention, learn these things very well. These are very important. These are all
fundamental basics. You should know all
of these things. I'll repeat this. What is this? Val, val or Va, we declare our
variable with this. After that, the name, we say the name of this value
variable, sorry, variable. The name of this
variable is binding. So after that, we can
use this binding, and even the thing inside
of that binding with that. And then after that, we can say Again, we want to use that binding. And even if we open another
scope in that area, let me say just area. Inside the new area in here, we can use that binding. But above that. For example, in here, I can't
use that binding. See, if I paste it
binding in here, we just not declare that. We just don't introduce that. So nobody knows what is this. We should first S, what is our binding. Okay. Just like that, You see the open in here. Just in here, yes, just in here and you see this
line all way down. We ellos in here. Open ellos. This area. We say our binding is exist, but only this area, only in this area
and and After we say val binding in this area and after this val
binding, not before. When we close the area, we can't use that
binding anymore. Let me give you one more example
let me say or this time, R H equals 22, and I say, I declare
my variable, I want to use in
here. Can I do that? No, first, This is
inside this and second, I use it before declaration. But if I say, this variable in
here, it's okay. And again, if my age
goes outside the area, there's no ge in here. Nobody knows where is the edge because we declare that in
here. So to close this. We have a function and we can use the things we declare
inside that function, only inside that function and the functions that are inside of that
function, not outside. Before I forgot,
I say we declare function with f.
This is the keyword. Let's clean this and also this. Let me fix this problem
in the next video. So our video doesn't
became very big.
38. Day 5: Gradle And view binding part 3: Gradial and view
binding part three. We want to fix our problem. We should use our
variable globally. Global variable is a
variable with global scope. I mean that it is visible
throughout the program. It has many levels and
we just want to see this variable rough the
functions that we need. Let me show you. As I say, if we declare a
variable in this place, we can access it in this area and because we
declare it in this place, we can access it in this area. So we go up in here, press in inter inter in here, right, w what al binding
control C control V. Then what? Then the type. What is this variable types? Type is its activity
main binding. It gives me error because we didn't give this
variable any value, and it says you should
give it some value. We fix this like this
que mark equals null. I just said you
didn't have to give this variable any
value. Just leave it. I know it's the rule. I must give this kind
of variable value. But for now, just leave it. Because of that, I give it null. Null means nothing. It's not equal zero. It's not a zero. It's
nothing absolutely nothing. It's empty, not a zero. U, it's not equals to zero. Why we did this because we
want to give this value, but inside and create
when we create our class, we want to give this
binding our value. Let me show you, if
I want to do this, I can simply control C and
give this value It's okay. But I don't want it like this. It. It's fine. You see. I want to be nothing and later I want to give
the value like this. In the tl, it's the rule. We want to have a
global variable. Global variable
must have a value. It's the rule in cat. This language have this root. But since we don't want, we should do this trick to
let it go for now. What? Remember, you must
give this thing value. I suppose you ask me, you give this
variable. I see that. What is this Why you put
a question mark in here? You see you must say my
variable can be null or not. By default, it cannot. But We add this question mark. You see if I remove this and give this variable and
null. It gives me error. But if I add this and say, it can be null. It's okay. I have no error. Let me
give you another example. Because we want to do this first project and basic fundamentals
as best as we can. Let's go. V, what, give it name. This is a name. Name what. For example, it's must be a string. I just say, I say it's a ring and I say
it's equal to null. But I have a problem. Did you remember, you must write these things
with capital or be. Sotlin is case sensitive. So you must write big capital S. If you write a small S, it's not a string. Just remember. Anyway,
what does it say? Null can be a value of
a non null type string. H. What should we do? We say this F name
first name can be nu. It's okay. If we don't say, it's strong. But if we do say it is okay. Okay, let's clean this and
give it space, and Extra tip. Do you remember we say you
can skip the value type? You don't have to say, what does these
things value type? Do you remember
But just in case, you give that
variable the value. Cutting can decide what
is these things type. For example, if I say, F name equals to, even an empties string or just space or a few characters
or any other thing. It's okay. But when we want
to give it null. No, it's not okay. We should say what is in
these things in the future. Even if we give
these things number, it recognized it's a number. But when we want to give
it null, it can recognize. Cotin is really good because it can recognize what kind
of variable is this. But only when you give
something to this variable. I remove this and extra example, as you can see, we
have this binding, and we didn't have to say what kind of
variable is this because we right away give
this thing value. It says, yes, it's
activity main binding. Long story short,
when we give null, we should define what is this because it can't
decide what is null. So because we
defined it in here, we don't need this val. And since we say val, we can give this value
variable another value. Y? Because we use val. Do you remember difference
between val or V and V, take one value. V can be rewrite many times. So to fix this, change this va to va. We continue this
at the next video.
39. Day 5: Gradle And View Binding Part 4: Gradial and view
binding part four. Welcome back. We
have some errors, red line for that error. You can see the
description of that error. What does it say? I say? The variable that you
defined can be null. It's not null. It's
not definitely null, but it can be null. Because null is nothing. This part said, I
don't accept nothing. You should do
something about it. You can't send something to me that might be nothing
or as I say, null. What should we do? I just came here
after that binding, put one and two of this sign. If you press shift and press
number one on your keyboard, you have the sign. Two of these I just write
and the error is gone. What does it say? It say, let it go, or simply you
tell that error, it's okay. I'm sure it's not
null. Why I do this? Because I'm sure
I give some data. It's not null anymore. So I can say, let it go. Oh, we just put two
exclamation mark. I think y pronunciation
is wrong. What exclamation
mark as I remember, and the error is gone. Please forgive me
for my low English. We have two more of these. What is this? It's
just my examples. So I remove this and
everything is fine. Let's continue. Now, do you
remember we just use this Y? Because it's sallow ball. It doesn't end here. What can I do with this
scallo ball variable, select all of this. I just say bind thing in there. T t n. I have my four buttons. Tn add that the one I want. Just like before it says, it can be null. Your binding can be null. I say, I'm sure it's not null. Let it go. Why it's not null? Because I just said
it has a value. I give the value here. Just so you know, your
program goes from to to down. What it means? This line is running, after that this line is running, after that this line is running. After that this line is running, that we say, we have the value. So before this line, our function, we give the value. So it's not not. It's always top to down
up to the bottom line 21, after that, line 22, after that 23 24. It's okay. Because we want to
learn very well, let me show you another way. We can use This question
mark and in here, question mark, it's also okay. What is the difference? One way and second way. We have two ways.
What's the difference? If we give it question
mark, if it's null, it doesn't give you error and just forget about
it and leave it. Just ignore it. Yes, et cetera. Just ignore this set of codes. So when we say this
question mark. After the variable,
that can be null. Where is it? That can be null. So I mean, if it's not null, do the job, run the code, but if it's null,
forget about it. So ignore no error. So you remember,
if you write this, you have error if it's null. But if like this, you just forget about
it and ignore it. The program ignore it
if it's null, no error. It gives you error
and stop the program, but it doesn't give you error
and just ignore the code. Entire code from here to down there. Ignore
the whole thing. One thing is good
about you learn from a programmer that
wrotes other programs. I can give you advice. I tell you, it's better
something like this. I tell you, it's better. You use this question mark. Many times, I use this question
mark instead of this Y. So during that if my
programs running, my program doesn't crash. And you see the point. I I don't write it in
here, it it's okay. You say if binding is
null. Forget about it. But BTN can also be null. So I say, Okay, if it's
not null, continue. Because of that, I have
two question mark, one for that part,
one for this part. You might ask, Okay, why didn't I write this question mark in
here? You see it's okay. Let me remove it. Okay. It has error. Now, it's okay. Why? Because I want you to see the different
way to do things. It's really important. You learning is
really important. And from my experience, I only use this
type of ignorance. When I just give the value. You can do it anyway
anywhere anytime, but I just use this
kind of it's okay. Then I just in the one or two
line before give the value. I'm sure this isn't no. But the other times other places I always use question Mark. This is my experience. One last thing. Why do I have this much repeat on
this because of course, you have, let me see, 66 line of code. Many of them are just in there, maybe 50 line of code. It is a really a small
project that we made, so we can teach you better. But imagine just imagine
instead of 66 line, you have a big
project in the future with 66,000 of lines. You like it or not. You can
have many of these problems. This kind of rules
for your own good. These are really important. Imagine that kind of project have error and
everything goes wrong. Stick to these important rules. I hope you'll be okay. Let's continue and have
many binding like this. I just minimize this
to have better view. Now, in here binding, and the question mark ptn minus and another
question mark. Just like that, you see, it's simple, simple and similar. Now, in here I have this. Let me just Commented. So you can see binding dot, just so you don't miss and confuse to
what should I write? E t first value. D first value, D first value, and of course, our que mark. F edit second binding mark dot ED, second value. And we even don't have to
put it in separate line. Just go here and press
or select and remove. Why? Because it's much smaller code
and we don't have to line. You see, we continuously repeat
binding binding binding. Binding in here,
binding in here. Or even in here, we should write binding. Isn't there a better way? Please remember all
of these things. But keep in mind, isn't there a better way? You should learn all of this. But from here, we
have this question. So what can I do? So I don't have to write these many bindings and
question mark and many things. Make it easier. Let's go up in here. Now, in here, I press tap tap. If you press one space, you go this much, but if you just be here, for example, and press tab, you jump to the next section. In next section, what do I do? I write. Finding. What's next? Question
mark. What's next? Dot. This is a good one. Apply. What just happened?
We write this app. This is a great
Android C cut code. This is a great code that Android studio in
Catlin provide for us. Let's just from
here to all down. Control x, come back here, control, and pace it. It helps me that I can remove all the bindings, how like this. Just look. This is the binding binding
question mark and dot remove. Binding question mark dot remove binding question mark dot. Let me just comment this and control C and
in here control. Because I want you to
have the examples. You can do this in
your code as well because I'd like you to know
all of the different ways. Let's continue in here remove. As you see, we don't have to write This question
mark, and it's yellow, y, because I just say this binding isn't
null, run this code. What is this code?
All of these codes? I don't have to check it again
with this question mark. I I remove it, it's okay. If I remove it, it's okay. No more question marks in here, if it's null, none of
this code will be run. Just I have to write
one question, Mark. I hope you understand
all of this. If not, please. After this video is
finished, review this video. These are really important tips. And if I don't write it in here, all of these are rank. I have to run it.
Now, let's continue. We have this text result. Just double click and control. I want to replace it. Select all of these and control. Just like that. You
see the second way? I just double click Control C, select all of these. Control. Double click control C, select all of these, control and remove and space because we don't
have to line anymore. It's really smaller. You see how short it became how better it became
smaller, it became. Now, down here, double Control
C and of course, control. Let me make it even better. We have this Difers value. Yes. What if we comment
this and comment this? First value, control C, first input, first input, and first input
and second value. We have second value, second value, second value? We don't need this anymore. We can just remove them. And again, first value
in here in here, in here. It's really smaller. I just can copy this control, x and go down here in control. You have the code in here, so my code isn't really big. I close it again, sort my code even I can copy these control X and
put it in here and don't give the value my result. But I keep it this way. Why? Because I think
it's more readable. It's easier to understand. But it's okay if I just control, this and put it in here. Like this. Let me show you, let me show you Control C, and t xt result tx is equal. We should open like
this and string. It is okay. What I prefer this one. First, I give the result into that value variable
and after that, the value in the variable, I put it in the
takes the result. It's easier to
understand better. Let's continue this into
next video. Thank you.
40. Day 5: Coding The Other Buttons: Coding the other buttons. Okay, where were we? Let's add the other two buttons. Copy the whole code. As you see, inter and control
V. What does it name? P t n, multiply, what else do you see
this minus in here? We change it to the
star or multiply. We can select it and copy
this or we can use the code. We already copy. Inter Control V, pace
another minus. What is this? P n. We have four btn, btn, d, and what should it be? Division, we change. This part and this part. We have division as well. Let's run our application. We press this between button, run the app. We wait. Our app just launched, it took 6 seconds. Hide this Because
it's a small app. It just took 6 seconds. Maybe bigger apps take
20 or 30 seconds. Okay. Let's try and
see what do we have. If I put seven and put two, add them, what do I have? Seven plus two
equals 97 minus two, equals five, seven divided
to two equals three. 3.5 but since we have integer, we don't have half. So 3.5 is three. I think in the future, we fix that as well. Anyway, and multiply
seven multiply two, seven, seven equals 14. All of our four buttons
are good and fine. Okay, I don't have the seven. I say plus. Please inter first number, minus inter first number
division first number. Or if I say two and say multiply two times two equals four. But if I remove this
two and say multiply, please in first number. I put four inside this
and remove this one. Check it again, division, second number, one, division, four minus equals three I, three, But if I don't
have this minus, please in the second number. It worked great. It's good. It's worked just fine. We stop our project, and in the next video, we make it even better. Just remember. Our purpose is not to make this calculator. We just make this calculator to show you the
basic fundamentals, so learn it very well.
41. Day 5: Returning Values from Functions: Returning values from
functions. Let's continue. We have this PTN ad, and we have this part. So check if there's
empty input or not. If we copy this and press
control F and we paste it, it's just pasted for me
because I just copy it. Anyway, let's check. We have just the
exact code in here. We have just the
exact code in here. We have just the
exact code in here. What just happened?
I have one, two, three, four of the same code. It is really bad why? As I said earlier, imagine, just imagine you have 92
line of code in here. But what if I have 10,000, 50,000 or even 100,000
lines of code. What then, if we just
repeat the same code, not four times 100 times. For example, if we imagine
these eight line of code, five line of codes, is a 5,000 line, 5,000 lines of code, if we'll repeat that
5,000 lines of codes. Ten times we have
50,000 lines of codes. It is 45,000 lines of
codes for no reason. And if we want to change
things inside that code, we have to edit in
here in here, in here. Is there a better way? So we change the code
in just one place, and we don't have to change it. Even if it uses 100 places, we go to every one of them and those exact
things in 100 places. What if I forgot one or two of those 100
places, I have error. So we shouldn't. We must not repeat
the same code. Let's use function. What is function?
It's a function. What does a function do? Function is a bunch of code
with the same purpose. For example, this
function with this name, with this fun for
introducing our function, The job of this function
is sit on click Listener. Because of that, I
say in it listeners. So I know what does
this function do? You can put any name, but you should give
the function a name. That you can understand
what does this function do? Because when you
have more functions, you might get confused. Name them carefully. This is really important. Let's continue.
Let's go down here. Where does this
function open in here and let's continue
this line this line, this line, this line, this line. It ends here. You see that over there. You see that. Let me
again click here here. You see that fun up
there that appears. It says, This closing part, it is for that function. So because I don't want to start a function
in another function. I press inter to
make it separately. It's another function. What should I write?
Function. Function, what? What do we want to do? I can't give this any name. And just like that. In here, this is my function. What does it color? Why should this
function colors gray? Because you never use it. Because of that,
it look like this. If you use it anywhere, even once, it's just fine. For example, you see,
I just copy this, paste it in here, and it's fine. I remove this. Let's continue. But we want to try another way. We create function like this. We want to do another way. So I remove this. Let's go up up up in here. Before this press tab
to the next line, tab to the next line, tab to the next
line, tab in here. Let me check it again. What does these codes do? They check? Is it empty? Let's call it not. Do you see a small and capital n t value y, B it's going to check
this going to check. Is it empty value or not? Y value, inputs. Puts is not empty inputs. So open, close. You just press shift and number nine and zero.
What does it say? It say, you call the function is not empty
input. I don't know any. It's right, because we
are not defined any, it's not empty inputs. We just create a function, but we delete that function
because we want to see. Is there another way? Yes, there is. What do
we want to do in here? We have this light bub. If you click on it, we have create function, is not empty inputs. And if we click on here, on this and press inter. Press Alt and inter. If we press Alt and inter,
these things opens. Let me try again, Alt and inter. These things opens
or the light bulb. As you can see,
under that rights. Click or press all plus inter. When this things opens, I just click this and
it creates for me. Function is not
empty inputs, easy, and even it writes
it to do for me because I should write
some codes inside. This is private, so you can't access to this function
from other classes. This is function. So you can call it inside
this class many times, even hundreds of times. It's okay. This is its name,
and let's continue. I tell you about
this part later. Okay. I just remove this part because I just
want to start coding. So let's go up, up, up. We have these. Just control C, I just copy these or
control x, why not? Go down, down, down,
paste in here. We don't have our binding. Let's go in here, press inter and write binding question mark do apply, and these all goes control. In here, control inter. Let's close this again to
be sure it range well. It. As you know, we just
finish our project. Our project works just fine. But we are not intend to
just create a calculator. We want to learn other things. Because of that, I
continue to coding other things to make
our code better. What I do, I check
if it's empty, put some errors if it's
empty, put some error. Now, let's go up in here. I just control X and say if shift and nine control V, Is not empty input. If it is not empty input. I check my function to
see it is empty or not. But we have a problem. What? It's not true,
It's not false. If works only true all false. So inside this if I
should have a condition. I don't have any condition, so we have a problem. We have this light
bulb. I press on it. What does it say? Change return type of call function to
Boulan just like this. This wants to make my
function, this function. As Boulan this function
returns blean, true or false. So let's go up and
say, Okay, I agree. Let's make it Blean.
Error is gone. Go down here. It's Boulan. This is the difference. Though my function
returns Blean now. This function do something and
return returns the result. I have an error in
here. What does it say? We need a return y because it should
return true or false. Fulan can have two
values true or false. I click in here and say
T, T, return False. If we reach in here,
we return false. Our error is gone. But we shouldn't reach
top down here. Why? Because if there's my e, I reach here after else, I should return
through Just in here, I should return true. I say everything is good. So I go down. I say else, return T, it's not empty, it's not empty, so return true. Anything else, return false. So I go up up up and say, if these things is
true, do the job. I remove this s, if it's true, do this job and close
it again. I sort it. If this is true, Calculate. I do this with this function. I just copy this. Control C, go down, select all of these. Haste. If it's true, do this again, and it,
and again. Control. I have zero results. Y Be I replace all
of these. Close d. I have one, two, three, and four
calling that function. I call that function four times. Instead of repeat
this code four times, I write it one time and
call this four times. Let's run our application
to see what do we have? Until here, I just want to
see if everything is okay. Press this run button. Since I already run the app, just run my app under a second. So I just press plus, please inter first number. Oh, it works. One. If I press minus, please inter second number, one minus zero, five minus one equals four,
what about division? Five. What about if I
clear this five, multiply? Please in first number. Seven, multiply
four, multiply 28, it just fors fine, stops up, minimize
it, and you see We do this all with
this function, we don't have to
write it four times. So we have a bunch of code
that do a unique thing. What is this unique thing? Is not empty input. Tucking is not empty inputs. If we return true means, is it not empty inputs? We say true means yes. If we say false, means no. Do you remember if
we press control and I want to see what
is my Dity first value. Click. Again, press control and click to see what is this? Click. This is
Edity first value, the first edit text, and we return value. Why? Because we want to
return, what just happened? What's the result
and it's bulion. So it's true or false. Not a number, not a
string, true or false. You remember, if this is true, we're not going to
Eels, we jump out. What do we What happens
if we jump out? It goes down here. It escapes all of these. So this else won't run, so we go after it. What does it have? False. For example,
if this is true, we don't have this, false. If it's true, we don't
have this false. But if we can go to
the else, return true. If we return anything, we're not going after
If we return here, we're not going after this, we won't return false. It stops in here. Whenever you return anything, you stops in there, and you won't go down. For example, in here. If I write anything
else, for example, return to ro, it
gives me a warning. Why? Because this never runs. You return false,
and this never runs. You see, reachable, you can't reach there because
you return in here. Whenever you return, it won't go any farther.
It just stop. I remove this. I hope you understand this well. Just like this
return, like that, if it's true, these things
run and won't go to the else. What if this binding is null? We have question mark. So All of these won't run, we return files, and we
won't take any error. We don't have any error. We already talk about this question mark
and what does it do? Let me just show you
one more cool thing. You see, to be sure
you understand. If you do you remember
if we return, the rest of these codes not run. So if we return to,
what does it say? It say the other
codes won't run. What do you write other things? If you return other
codes won't run. And if you see, it said reachable code. Because you make them
unreachable in here. The stops in here. You don't have any if or things. It just run and the
stops here every time. The other codes worthless. And for sort thing, just close it again
and one more thing. Instead of four times, we write one time. Even if we want to
use it 1,000 times, it's okay, even if this code instead of ten
lines is 1,000 lines. It's okay. You want
to use it 100 times, you don't have to write
100,000 of lines. You write 1,000 lines, and you use it 100 times. And if you want to change
anything, What, for example? For example, you see we only
have one line after the e. We can remove this open
and ellos, remove, remove. Instead of remove this four times in the beginning
of this video, we just remove it
in here and all the other We don't have to do
even if we use it 100 times, we correct it one place in this function and all places
you call this function. It's okay, you don't have to change it all of those places. I think it's enough
for this video. I don't want it to make this long and I hope
you understand it. Let's continue into
the next video.
42. Day 5: Input Values of a Function: Input values of a
function. Welcome back. Let's go up. We have this input. What are these gratings? These are the codes
that we never used. You see this yellow thing. This is warning. We have warnings. What should we do?
We click on it. What does it say? Unused
import, unused import. We have four of these
four next to the warning, four of these, and here
one, two, three, four. On the line, six, seven, eight, nine, on the line six,
seven, eight, nine. If you don't see this, you just click in here. Click, Klick Klick, click, or you can minimize it, hide it. Minimize, and then click. What if instead of line six, I be somewhere else. For example, I'm here, and this is 1,000 line. I want to see line seven. I just click on this. No one click. Double
click on this. It takes me to line seven, takes me to line eight, takes me to line nine, line six, just like that. So what should I do? Instead, you never
use that unused. So I I, for example, line seven, just select this and remove with packet
space, I remove it. What just happened? I
just have line 68, nine. I just have three warnings, one of them gone, done. L et me do it again
with this one. This one gone as well. I want to show you another way. Do you see this light bulb? Click or press A inter? I just click in here, I just click, optimize
Imports. What should we do? Let's just click it
and see. It remove. It removes all the unused import where are my warnings
gone finished. Done. It's good. Let's continue. Can we create another function?
Yes, of course. For example, we
have adding here. We just press in there
and came back in here. I said, Add Ps. For example, it's not good. Let me say numbers. It's better. Shift nine and we don't need shift zero because
it adds it itself. So I want to create
this function, give this function two numbers and it gives me back the result. Add them. So I just copy this
part Control C, I divide them with this. It's just the button on my
keyboard next to the M. I press that control. I mean, the next button to the M right one is
this for separating. Of course, for the
first one, control, instead of second
value, EDT first value. I don't do that with
this integer value of. You know the things,
how does it work? I just write it in
this way so you know. You can do both with dot to int. So I can remove this and
I have this ad numbers. One way for creating a function is we just write the
function like this, click on it and click on
this light b or press A plus inter and create the function with
the name ad numbers. So We have this function.
What's the difference. This function takes inputs from me and gives me
one return result. You see, we return Ban. Now we want to return integer. So I have first, input. I just press tab. It's in Another tab. Second, input. Another tab. I'd like to
remain in Another tab. You can't write in with a small. You don't have in with a small. So you should write P and T. These are important. So another tab and finished. This is my private, so I just can access to it
from inside that class. Function. So it's a function. It's a bunch of code that
I write just one time for a specific purpose
and use it as many times as I like.
What does it name? It's ad number. I call it. I name it ad number. So I know what does it do? Be very careful with the naming. I'd like to write a
small letter to a start and pick letter capital
letter for each next words. You can do whatever you like, but I like this way. Same for the variable lambs, as you can see, I write
in with big capital I. You can't write
them with a small. It's case sensitive
programming language. Because of that, you have
to be careful with that. I don't like ad. Let me just say it's
stum and of course, I have error in here
because it expects ad. So I changed it as
well. It's sum. Let's go back. So I
have stum numbers. So I pressed cap next slide. Another tap in here, I return return return,
what? First input. Of course, P second input. It's really simple,
one line of put. I just write it front of return. To make it smaller. Even I don't write a variable and declare a
variable in here to add them. I just write them
front of return, and it returns the int. Close it again and remove this. You can see just like
that, returns b return. Integer and we just
these numbers. Be careful when you write. This want to return in, you should return in. When you write, this
should return Boolean, you should return true or false. You should return Blean. I explain all the function, so I won't repeat
it, but be careful. If you just have one input, you don't need this. But if you have more
than one, you add this. This character is next to the M on your
keyboard, write to it. I don't shift, I just click on, press on the button next
to the M to write this. I hope your keyboard
just like me. And you can add many others. If you press here, you can add another input
what we don't need. Let's just check once more, before just before
create the function, we should know what do we want. I want some numbers, and how many inputs do we have? I have two inputs.
And what do we want? As I say, I want some Since we return it
from this function, I even don't need this variable. Let me just select
it and remove it. Select the Control X, pasted in here and one inter in here and remove
this Inter in here, remove the values in here. I just want to
organize it like this. So sum number, first value, second value to a string. You see how noice
and organize this and I clear all of
this, and even this. This is how small this can be. Checking empty is a function. Some the numbers is a function. We know our input, and we show our output
in text result. This is the whole
code for adding. You see how easy and small
and well organized is this. So if I have a very big program, if I organize it like this, I have very, very few errors. Always make it organize. Let me just compare
that this to this. This is really better. So what should I do? I just go down and say, Let's try this one more time. I don't want to
write them up there. I just copy here. Inter control. I have another sum, so I shouldn't write two
function with the same name. I write minus and it's gray
y because we never use it. We also have one and two input. So we just want to
subtract from each other. First input minus second
input, just like that. One more time, why not
inter and control V? What's this? What is this? It's division
D. What do we have in here, division, first
input, second input, division, I don't like
to write all of this. So, I just copy. I I write up there, I should define the d, the d and other things. I don't like that. I copy since I write it up here and paste and
paste and change it. It is really easier, and I enjoy it more. I hope you too. Don't call it laziness. This is more smart. So once more, intercontrol
V and multiply and all thing same change multiply first
input and second input. So I have three gray function
because I never use them. Let's go and use them Inside the if from here
to here. What do I have? TX result, and I
organize it very well. So I just control C, and even in here inside
the from here to here. Control TC result, some. No, not some y? Because I want to minus
numbers. Check it out. It's not gray anymore. Why? Because I use it here. The next one, remove here and inside this select
this control, we very, very well organized, and this is multiply and we multiply
numbers, delete delete. And I have this. One
more time came here. Remove this inside the
control V and guess what? Division. I just don't want to
click on press delete. So select this check. You see the same name, it's okay and these things used. So this is my well organized
code functions. I believe A good application, a
good Android application, a good Android program
is the program that have the least line of code. And very organized. So you minimize your errors. You can I can't make
it any shorter. Or maybe, for example, if because I just have
one next line after if, I can remove this and this. Why? Because if you have
one line after, you can't remove that area, a specific area locators. Just like that. Just remember, it's
not four line. It's one line. I just inter. I just press inter. If I remove this inter, is all our one line
because of that. I have this one line and I
can remove that characters. And I can do it in here and in here and in here, cyli delete. Even now, we have fewer code. Let me show you
it's just one line, delete and delete, and
just like that and delete. You see, it's one line. I put them under each
other to be more clear, but it's just one line. What's next? Remember, if I
have another thing in here, I should put these codes inside that start and closing area. If not, my e only consider
the first line, not the rest. But in one line it ok. And kilos. Here, remove. And I go down here
and right shift and this button just
above inter to sort our code or organize them. I go up here and remove this as well because I want to have as much as little coat that
I can remove all the extras. This is very better. Yes, yes, it's good. We still have this warning, but it's not important warning. It's weak warning. Let me just show
you this as well. For example, it says, property binding could
be private on line 11. This is the thing
that we talk about. I just double click on it
and it takes me to line 11. Okay, I said, make it private. So from another class, you can't reach them. It seems reasonable. I don't want, and it's better don't access them
from another class. Okay, I accept
this week warning. I can click in this light bu or press plus in and make
it private private. What just happened? You can't access this binding
from another class. You can access it from
all this main activity, but not another Klas. And what about line 20? Okay. Make this function
private as well. I came just here or
plus call inter. Make this private and I
don't have any warning. This is a great code. I don't have any more warning. What do I have in here
instead of those warnings? I have this beautiful
green check. I love it. Why? Because when I
have the green check, it means I don't have any
problem inside my code. Even the weak warnings, I took care of them. If I click it, I don't
have any to have this green check on your classes all the
time as much as you can. This is really good. Try to have this green check. In the next video, I give you some extra tip and really quick reviews on some things and tell
you extra tips. I could be sure we don't miss
any important basic things. Thanks for watching. Join
me with the next video.
43. Day 5: Extra Tips: Extra tips. Let's have a few extra
tips and a quick review. Let's review very quickly
and close the day. Okay. We create a
project from zero and create the activity
for our coding. You should get used to activity because everything is activity, and you work with it a lot. How did I make it? Just right click New and then activity. And I click MTV activity,
just like this. I just told you, I
have this activity, but I also have a layout. Why? Because I should show my things, my data on something. So I have a layout as well. It should be with small letters and shouldn't have a
space on the layout name. You see, if I just press space, it says layout name is not
set to a valid resource name. I delete it. It's okay. Big A also have a problem. And if I check this
launcher activity, This activity became
my first activity. When I launch my app. This activity shows itself. I became my first page. And also, we have the
select source language. Carlin or Java, we use Catlin oy Cotl because
Google itself recommended, and it's really better than Jo. I think it's better than Java, so I use Catlin. Okay, let's cancel this with this cancel button or
this Klose button. Anyway, I have my codes
inside this Catlin an java, and if I want new, I right click on this place. And my layouts are
under the resource. F under the layout. F. This is my activity main. Andre Studio automatically add my main activity in here
and my layout in here. Let's visit our
layout, double clich. This is my layout. And minimize this.
This is my layout. This is my visible
part of the project. What should we do
when we click on something or the other
things? It's not here. It's on cutline file. But in here, we just work
with the visible thing. What should we show and
how arrange the things. Arrange the objects. Let's just see the cut in file. What should we do, if
anything happens on our view? If somebody click on
something or anything else, how should we work with
datas in cutting language, in this main activity do cut, we decide these kind of things. We have this create method. When does it happens when this activity launches
creates be created. Let me say. Okay, Let me back in
our visible thing. We have this first number, second number. What are these? These are text input edit text. The user can enter
the data inside them. We even give them
input type number. We also use material y because Google self recommend this
Andrew Studio, recommend this. These are nicer text input
edit text with extra features. Instead of regular and
basic text input text. You see, let me just go here
and write this edit text. We have this simple edit text, but we don't want it
because it's too simple. We can use it as well. I don't want it. Even I make them different
from each other so you can see there's
many different ways to conflict these edit texts. Just remember, this is my text input edit text that
user inter data inside. But I have this text
input layout as well. I give this another kind of data and It helps to make text
input edit text looks better. For example, I put
inside this max length, ten, it adds this you see
this zero out of ten. It gives me even more
beautiful thing and more power to make my text
input edit text better. It's my layout thing. But the data data goes
inside text input edit text. So long story short, I can't get data inside my Catlin code
them this input layouts. I can't do that. I should take
it from edit first value. I can't take it from here. Don't confuse with this. This is my visible thing and you don't put
data inside it. This text box is in here. It means this thing doesn't
have even that text. Let me show you Control C, if I put it in here first value. This thing doesn't
have that text. So we understand the user inters data inside
this edit text. We also have these
buttons, these buttons. We also use material
for these buttons. Why? Because it's more beautiful
and More recommended. You can do more things
with these buttons and read the studio itself recommend this and
introduce these. I develop this. I want to put them in a
line with each other. What should I do? I use the linear layout,
this linear layout. Because I want to show
them together as a line. I put them together
and I say these should show with each other
horizontally like this. We can also stay vertical, but in this case,
we need horizontal. We also give weight to each button so each
of them can have 25% of the space from 100% of this space that
linear layout gives them. Some of the layouts might
doesn't support this weight, but linear layout
support the weight. Just be careful. You can't use every property you
see in everywhere. The whole is one, and we give
25% to each of these four. Also this text view, what is this text view? We want to show data. We also add this view, hide this view because
we want to give it two D height,
and match parent. What is match parent? The
whole space in the parent, and we give it the height two D, and we give it the color black. So we have a lone with black color with the height
of two DP with the w, match parent means whole thing. As much as you can
inside your parent because we don't have line inside and the
studio, we use this. And also, we have layout
constraint bottom to top of. We say, we should show this
to top of Txt result label. Sticks to Txt result
label that we see. And even you can see
that arrow that says, I stick my bottom to the top of this We also
have an text view. Why? Because we want to show our final
result inside this. We introduce you tools
and say it didn't show it doesn't show inside
the final result even into the emulator
when you run. It just for you when
you design the app. It's for the
programmeran designer. So you can see if
you put 20 digits, for example, it takes this
much inside your app. Anyway, we say if we want to access to button
or other things, we first should find them. So we can say, I want to
work with that object. How do we do that? We came to code and say, Just down here, you can do this. We find view by ID and
give the type of object. For example, text input, edit text and from the reserves, from the IDs, you give the ID, and you have your object. We also said this
has too much code. We can make our code lower
our programs smaller, our codes lower.
What should we do? We use binding and we
defined this binding. As you remember, before
we use this binding, we came and say inside
this cradle down here, V binding equals true. We can use binding. Then we told you what is global variable and why
should we use this global? And then on create, we give it the value. We also talk about
null and null labor. We also say because our
activity is activity main, we have this activity
main binding. It's based on that name. For example, if it's logging, we have logging binding. And even if press control and in this activity main
binding, click on it. We see our activity main because it is equal this activity may. We have this binding
field with this data, and then we give our set
content view this binding, because we want to connect this main activity
with the view. What do I want from
the binding that we just said it's
filled b activity main. We want the root. We want the root of this binding to connect with
our main activity. After that, we have this init
listener. What does it do? This is a function that
are all kl listeners. We put them all
inside innit listener inside this function. We also introduce app. Also say why we put this question mark on
this null able variable. If it's null, this
apply part that contains the whole code
until here doesn't run. We doesn't get any error. We won't have errors. Another good thing
is we don't have to write binding PN ad. Binding question mark PN ad. We get rid of This part
for the whole these BTN. Binding question mark dot. We don't repeat that here here. It's just really better. As a result, we
directly can access to this BTN ad without
any extra code. Then we say set on
click listener. What is set on click Listener. It listens until you
click on something. Then when you click
on this button, it runs this code. For example, this is my button. I want to do something whenever
somebody, click on it. So I say sit and click listener. Wait until somebody
somebody click on that. Then I have this
condition and this if I check is this inputs
empty or not. Why? Because if these are empty, I can't add them. How can I add one number
with empty thing? An empty thing, I can't do that with plus or minus or division. How can I divide a
number on nothing, even not zero on nothing.
I can't do that. I check are they empty. We also write a function for any poten that we
want to do something. We give our first and
second input for inputs, and we put the result
inside ix result. For example, let me show
you the sum number. We take first input
and second input. They are ins, and add them
together, then return them. What is the type of this
function that returns. It's int. I have int for my
output and my inputs. As I say, we put these
results into tixy result into the property
of this tixty result, property, have a name, what does it is text, and we have to make it string because this text
just take string. If we want to give it
number like this ins, it doesn't take
it. Just a string. Since we confit this function
and it's really good, We put in proper
name and add them, we just copy this and
paste it many times. Because we don't want
to write it again. We just change
this and the name, even not the whole name, the first part of the name. Why? Because I prefer to
write less code, do more. Exactly because of that, we write functions to
write less code, do more. We also learn a very good thing. This green check. If there is a problem, we can fix it. So we don't have any
problem even we problems, and as a result, when all problems are fixed, we have this green check. So we are in a great condition. Before I forgot, we also have inside this resource,
more than layout. We have these values. What does we have inside
it? We have colors. We have diamonds, so
we can give amount of spaces or other
diamonds in this. For example, if we
want to give margin, we give it inside these
diamonds and then use it. If we want to change
this eight to nine, we do this one time and everywhere somehow looks
like our functions. We change one place and all the other places
takes the effect. It's the same thing for colors. We change one color
in one place and all the places that we
use that color, change. We also have these strings. These are important as well. We have default string English, and we can't have other
language default. My has default language of
English because English people Or my targets. Or I live in an English country. But also Arabic people
might use my apps. I add another language Arabic
for my second language, or even it can be French. My second language
can be French, can be Russian, can be Chinese. Why do I use Arabic? Because the English
are left to right, and Arabic are right to left. The difference because
they are difference. In the future, I can teach you a little more with this left
to right and right to left. I even consider that. And everywhere, every time
I want to write anything, I use this even if I want to
write this plus, I use SCR. So if I want to
change this text, I change it here, everywhere I use
this text change. I don't have to check
everywhere to see. Okay, I write one letter wrong. Let's search all the
app entire app to see. Okay, I write just a
letter right or wrong. I give the translator in
my company the whole text. So he or she checks is
this wrong or right, and compare it to
the English text. These very pro tip,
very professional tips. Because of that, please. These first days are
really important. You must learn these
very carefully. If you don't understand some of them, repeat those videos. I provide as much as I can many examples so you can
understand them well. Your learning is a
very important thing. Simply because you
chose me to teach you. Because of that,
I'm responsible. I try to teach you well. I hope you learn
these things well. One other thing, let me just
show you this manifest. This is my manifest. This is my app identity. This is what my app is. For example, what
is my app icon? Even my team, what is my team? What is my target API? All important data like identity card that
you have is in here. I won't explain this anymore. And you know each
activity you have, you have one activity in here, and other datas are here. In the next video, we have a small quiz, and we wrap it up this day.
44. Day 5: Day5Quiz: Page five, quiz questions. How do I enable view
binding? Question one. How do I enable view binding? Question two. What is
a global variable? If it's too quick for you, you can pause the video, then write your answer. Into the next video, you check your answers anyway. What is a global varia? Question three, How to take
input from user in function. How to take input from
user in function. Into the next video, you can check the
answers. Thank you.
45. Day 6: Day5QuizAnswers: Day five quiz answers. Question one, how do I
enable view binding? You see, you just go to this build grade C T S. No
that ends with project. That one with module,
and inside that, you add built pictures
inside that you add view binding equals
true just like that. Question two, what is
a global variable? Is variables that are created
outside of a function. Why? Because we can access to these variables from any
function inside that class. We even have variables that can access from other
classes as well. We reach to them. I think through future courses, maybe After their 20 or 30, we reach that kind of variables. Question three, how to take
input from user in function. Just like that first input. Second input, the type is in, the type is in, and the output, just like this, the output is in, and we return output, just like this, step four, First input plus, second input. This is our output.
46. Day 6: Decimal value: Decimal value. Welcome back. This is our last day
of very basic level. Let's run the up. Hi this. We put 83 and plus eight plus three equals 11 minus
eight minus three equals five, and multiply eight,
multiply three equals 24. H that division press two, but two multiply
three equal six. I don't have the decimal part. You see, if I enter seven, I s have two, I just start this app
and now I stop this app. Minimize this. My
code is in here. I have these four functions, for some four minus for
division and for multiply. In division, I have two number, first input, second input. They are integer, and my
output is integer as well. I divide them to each other and my result is integer
as well as we can see. So I don't have any
decimal points. And I don't have any decimal
number in my results. We explain different
type of variables. For example, R A is a
string, it's a string. It's text, R p equals integer. Like one, two, three, it can store numbers. And of course, R, C, what is it a It can
be true or false. Even we return ban in one of
our functions, you can see. What else I also have variable d equals ft and variable
equals double. These two are decimals? It can have, for
example, 2.5, 3.5, 3.6, you can sort decimal numbers in the Let's give them some
values for a string. I pressed equals. I press shift and the
button next to the inter to write this
character and Androuo, write the other one
for closing for me. I just write a BC or
number or the name. This is a string. The number. I can give it two or 23 or 234. This is the integer. B. I can give this
true or false. I give it True. When do we use ban? When we want to say something
is yes or no to force. When should we say
yes or no to force, for example, in our function, you see, we want to
say is not empty, yes or no. We use ban. How about fellow, we can give it Decimal lumber,
for example, 3.40. It gives me error because
if you want to give, decimal lumber to
a fat variable, you should put a F at the end. Just remember. Okay,
what else I have double? Let's give this number as well. 3.14 F. It gives me error. Y? Because I should not put an F. Put a F at the end of a
double number. Remove it. It's okay. But at the
end of a load number, I Put F. I hope you understand
all of this. Very well. Let's just close it again, shift and the bottom
on the up of inter. It's sort our code for us. Let me just check what
happened if I say 0.2 I can't put a decimal
lumber into a in. It gives me error, so I remove it. One more thing. You have a string in here. You can write one,
two, three, four. You write number,
but it's string. If you write AAA, it's okay. Why? Because it's string? Now, if I press inter
and say A to int. It's okay. I can
make my A to an int. Y, because I put
integer inside this. One more thing, we can say one, two, three, four, five, 67890 Again, one
to what happened. It says, your number is too big. You can't put this much
number inside integer. There's another variable we talk about in the
future lessons. But for now, we use int
and you just should know, there's a limitation
that you can put number inside any data
inside, any variable. For example, let's
kill these these. You see ten digits. If you put ten digits
inside and in, it's okay. And of course, I think
about 2 billion. No, no. Even this, you can't
less than this. I think in the slides
in previous lessons, we talk about the limitation,
exact limitation. But as you can see, if you deal is one of these
and even you put nine. For a start, it's okay, so I should understand
if I want to use it, I should maximum, for example, maximum 999 million is my maximum number I can
put in this for more, it's better to use
bigger variable. Of course, it can a
sore 1 billion or more, but it's better to not use
it in that much number. And try to not break
the limitations. We're not talking about long instead of in in the
future, we talk about it, but not for now, those type of variables
for the future. One more thing, if I write
inside this string, A B C, but I say dot to ind, I have error or y because
it's not a number. I should be careful. What do I want cast to what? I should just convert my number into number from that
string or anything else. Let me try one more thing. Can I give this float? For example, just number
three, an integer? No, I cannot. I should
give it. Float. Let me just comment
this, comment this. Comment all of these. So when you see the source, you can check them out. Anyway, I don't want int. Do you remember our problem? I want float. I want flow for my output. I have error. What
just happened? It said you have d, you have in, you divide in to end, and the result is in. You can't have
belod as a result. This is our error. Okay, k. Let me check it. You can't convert
to in when they are divided to each other to a
fellow so let me do this Dt Two flowed. Now, if one of the numbers
is followed, it's okay. Our result is followed. Of course, you see,
the problem is solved, but just to be sure I
can write two flow. But even one of them is. Let's run the up. I'm waiting. Now,
what do I have? Eight T division, two
point D six and seven. Cutlin round the last number up y because this six
is closer to 10220. Because of that makes the seven from the next number
to seven, not five. This calls round up. Of course, since we're
at level very beginner, I shouldn't tell this. Okay, let's just
skip this thing. Anyway, we have our
decimal result. Let me check another thing. 52 and sion 2.5, simply L et me just
check one thing. I have eight, two, three, and division, I have this one, two, three, four, five, six, seven number after the dot. Seven number after
the dot. Stop. So I have common seven
number after the dot. Now, I want to check,
how about double? Because I want to see what's the difference between
float and double. I select this. I write double, and of course, to flood two double. Even if one of them
is double, It's okay. It gives you double. But I want to be sure and to double two double double
and output is double. Just remember, if
you have two fd, you can't have output as
a double because of that, I put one of them
at least double. Anyway, we put for
both of them double. Anyway, let's run
the ap. I'm waiting. It's running mount,
and if I say five, and I say two division, I still have 2.5, no difference. But if I say 83, and division, I see
the difference, Let me look at this very closer. Let's count one, two, three, four, five, 67. Okay, eight, nine, ten, 11, 12, 13, 14, 15, 16 16. Instead of seven
number after that dot, I have 16 number. After that dot for D Simar. So double has more capacity, and it's more specific. So we need more specific and accurate
results. We use double. But when we don't need
that much accuracy, we can use fellow
In our calculator, it's a really simple calculator. So we use fellow float to flow, to flow because we don't
need that much accuracy. Of course. Okay. We have a few small things
on the next video. Because we want to finish
beginner level today. Maybe we have APK output and maybe close keyboard
and some other things. And then we close beginner level and
start beginner level. I try as much as
I can to explain very small details in this
level in a few first days. So you have basic and fundamental
knowledge of program. So in the future and next day, you have as low as low
as we can problem as little as we can problem and I have a good start for
this programming journey. Thanks for your attention. We continue until
the next video.
47. Day 6: Export Apk And Tips Part1: Export APK and tips
part one. Welcome back. Let's have a few extra tips
and learn some new ts. Until now, we use
emulator press app, and we saw our app. But can we make an APK? Yes, of course,
go to build menu. Build a Bundles AP case. You see this on the right. You have two options. I just press build AP case. This is build my APK. I'm waiting so it's finished. My APK build it successfully, and if I press on locate, I can see my APK location. Let's press on it. I just
click on this and click on locate and I see This
folder open debug folder. I have this APK file. Just remember, this way, I have a debug APK. It's not a release. What is a release we talk about release output
in the future lessons. But for now, you can easily and without very
complicated steps, have a APK and stud
it on your phone. Just copy this on your phone and open it
and press in a stud. You can use this APK. Of course, if you need, you should active permission to install debug
APCs on your phone. It depends on your phone
and your Android version. You phone Android version. You can find tutorials to
do that on the Internet. So remember, It's not for, for example, play a
store or other stores. It's just for debugging
on your own phone. So how do we do this? We just click on menu, go to build menu. Build a bundles APKs, and we build an APK. If we have error,
we fail to do that. But since we don't
have any error, we can do this and
have our file. We say we talk about
release in the future, but just so you know, release for releasing
your app on the stores, for example, Google Play Store. Let's run the app again. Press run and wait. If I click in here, I have this keyboard. One, two. If I click in here two, I have this keyboard as well. Let's press plus. This keyboard is a seal in here. This is a problem.
You see the problem? I should press this
check to close it. It's better to change
these buttons. So if I press any of them, click on any of these buttons, my keyboard close
close automatically. So I didn't see this. It's
look like I just press this. If I press any of them, it should do just
like this, close it. Let's just stop this
up and minimize this. And I tell you about it. If you have any error, you can't pull it. Let me just show you that. For example, if I have
one space in here, I have error in this line. You see red, red, red. I have err in here. Okay, so because I
have err in here, I can't pill it. Where else I have the error. You see if I go up, I have error in here. This just I can have a
preview you see my preview. If I go on red in
here and I click, go back to here. Let's go up again. We have error in here. And we can have a preview on that and click in
here, go back in here. And also, I have
this main activity. It has red underline y
because it has error. I have red underline in here, I have red under the problem. And even if I screw up, I have red error in here. It shows me where is the error. And even on this. Let me just open it. Red under
line and red under line. This is red dir line. It just shows me, we have problem until
I came here and see, Okay, we have a problem in here. And let me just go to build
build up bundle AP case, and I have error. But what happens if I
press build AP case? Wait. You have exception. There on this file, line 65, if I click on it, I have error in line 65. I just take me to the error. So if I remove this
extra space, it's okay. Everything is now just fine. Okay. Let's press inter
in here. Just in here. Let's create function
with no input. Hide hide what? K. K. Let's open and
close and no input. Just inter. This
is our function. Get this system service inter. It needs an input. Context, of course,
context with big C. If you write a small C, you can't have that context. Because we are in
very beginner level. I insist that every time. You should now I think
understand it very well. Do you see capital. I shouldn't write.
I should write. Write Big input input
method service. And at the end of
that shift and zero, and I press home shift and nine. I add two parentheses, and I just press one batch. Okay, I'm here as we are
at very beginner level, but this is not very
beginner level. You don't mind what do
we write? Just write it. Input method manage dot We want to hide K hight so
input from window. And I just say binding e mark and root dot window token. Ke second parameter zero, and another mark. I forgot that. Let me just minimize this height this
and you can see the code. I press inter in here, so you can easily see my code. So we write our code
to close the keyboard. Our soft keyboard, of course, Let me just explain more. I don't want to explain
this code. It's okay. You don't have to understand
it in very beginner level. But just let me
explain some things. For example, let me
just forget about it. You have set click listener. You don't have to know all
the things on the background. Andrew D Studio
and Catlin do for set and click
listener. It's okay. You don't have to know. You just click Listener on your button. Andrew Sudio and Catlin
language, do it for you. You just should do
your code inside that and then user click on it, this code runs Easy
Z, just like that. This is Catlin and Andrew
Sudio method function. What is this method
and function? This is predefined function. What I explain. For example, do you see you create
this function? And one line of code. No matter and it doesn't
concern anyone, any user. What do you do inside? Imagine another user. Want to use your function. That user only call
this function. Send you two numbers and
take one number back, and this number is
some of this and this. We understand it very well. That user shouldn't know, shouldn't care about
what do you do inside? What do you do inside
the other one? What do you do inside
the other one? This method gives me division
which decimal point. User not know and should
not care Just like that, we don't know, and we shouldn't know what happened on
set click listener. We just should know when someone click Set click listener, run. And then we can run our
code. Same as this. We just write another codes that are predefined
on this Android, the Studio and cut language, So we hi keyboard
on our program. But we should not know
all specific things. What does it work? How does it work? Of course, in the future methods, we know Much, much more, but for now, don't worry. We write this code
and read the studio, do it for us and
cut the language. Of course. One more
thing, I call this. I put binding inside this, and I write my binding variable. Why? Because I write my
variable with binding name. You see, I declare this
variable as binding. If I call it anything else, and if you call
it anything else, you should write
it another thing. The thing that you call binding is the name
that we just called. Don't think is a fixed thing. No, we write binding for our
variable because of that, we call binding in here. Even this, we call
binding in here because our first variable that we
defined has the name binding. If we call it anything else, in here it's changed as well. But this part apply is fixed. For example. Another example, this part is fixed, but this binding isn't fixed. This part is fixed. This binding, no, of course, root and window token are fixed. Just this binding is
the name that you call. As I say, I just
press control to see where does this thing goes? You see line 2227 and lots
of code and comments. I should not know these
codes and the other things, and how does these things do. Oh, my God, too much codes. No. I just use this input
method manager. I use this input method
manager. This part. And in the future, we know some of these, only some of these, only the parts
that we shod know. Because we can't We really cannot read
all of the codes. Even I I write Android programs. More than ten years. Of course. I think my first program
is about 11 years ago. But ten years or
more than ten years. So should I know
all of these codes? No, I can't. There are, thousands of
codes in different methods, and no, no, no, I can't. So do you don't worry.
Please don't worry. So let's just copy
this until here, control C, Then what then go after every set
and click listener. Inter Control. Inter
Control Inter Control. I really don't like to
write all the codes. So I just copy in Control. I suggest you do this as well joy and do your
job smart, not hard. Because of that, exactly because of that, we
create function. So we do a smart, not hard, we write once. We use many times
from that code. Let's run our app. Minimize this write 11 and 22, and press plus.
What just happened? Let me show you
again. Click in here, press minus, click
in here, division. Click in here, multiply
our soft key keyboard, virtual keyboard
in here, heights. As I say, what does each part of the code
do? We should not know. Okay, I know we use system
service and other things. But we should not get
confused in the start. Because it's not a
complicated code, just hide your soft
input from window. But we learn this in the
future and many other things. We might just say, Okay, please use this code. Another example simple
example, this apply. Do you know what
does this part do? It has many codes inside
to do your thing. But We just use it to
make our life easier. We use it even here
to make our life easier to make our code
the and one more thing, the binding to do the
binding has lots of code, but we should not know
the specific things that behind the scene does. This is the I think basic thing that you should
know about the functions. We write these things, so the user or ourselves
when we want to use them, we don't care about the inside. We just use the function. And then we have error, as I say, we fix the inside. And after that, we don't
care about the code. We just use the function. For example, we come
and say to followed. After that, we don't
care about the code. We just use the division. Okay, I think it's
enough for this C D. We continue in the next
into the next part and learn a few more things to wrap it up very
beginner level. Thank you a lot.
48. Day 6: Export Apk And Tips Part2: X port APK and tips part two. Okay, welcome back.
Where were we? We're looking at our
project to see do we have any extra ting to learn before closing
where we began a level? We just export an APK
in previous video. Now, let's continue.
First thing first. Let's look at that
yellow warning. We have one week warning. What does it say? It says function high keyboard
could be private. Where is it? I
double click on it. It's on line 76. It's in here. So I want to do it. Make high keyboard. Private. Just like that on the
right as we can see, private function, click, and I have this
private function. Now, no problem
in main activity. I hide this and I have
this green check. It's really better. Next tip, when we just
install our Android studio, we have welcome project. But how about now? We don't have that anymore. But we can create new project by using file menu
from the main menu. I just press main menu. I have this file menu. New what new project. Because I want to
create a new project, I just click on it. I have all of the template. Let's just look at them
to see what do we have. But first, let me just close
these and look at the open. If I click open, I can open my aller projects. You see at the moment, I'm in Day six, and this is my project holder. This is my project,
my calculator. You see this green android icon because it's a project
and I can open it. I just select this
and click Okay, and my project will be opened. Okay, Let's just cancel this
and go back to new project. Let's look at the left side. I have phone and tablet. I also have OS. It's for the watch Android watches that people wear
with very small screen. You see, just like
that, a small screen. And I can create a new app
with select one of these. And it just does a few
first things for my app. I can create empiba App or emptier a bit Ty and
the other thing. And I also have this television. What is this television? It's for TVs that has Android. I can create for TV
that has Android. And run on that TV. It also has t activity or
with views and other things. And even the other things, we don't do things with these. Let's just back to
phone and tablet. And from the Internet, you can download other
templates as well. But let's go back to
phone and tablet. You have no activity
without anything or empty activity and empty
and simple activity. So as we understand, these are all some pre
return activities. These projects is good
for helping us start. Soon. Now activity is empty. The empty activity,
as you can see, the icon is the different way. We don't talk about that now. Basic view activities create, as you can see these basic
tools for us as well. So we have simple
menu, simple button. The next one gives us a few taps that we can switch
between these tabs. The next one just gives
us empty activity. Simple as we just create. Can see this one as
menu, for example, you can put profile and
other thing on the top and create game activity with
Cips plus neative Cip plus. I think it's enough just
talk about all of this. Of course, it's obvious,
responsive view. Creates view that
responsive for you. Responsive is the
kind of thing that when your screen becomes bigger
or smaller, change size. We have this on the web as well. If you forgot what what
and which one of them do what you just can simply look at the
pictures. It's really easy. For example, this
picture has nothing and under that says
you, what does it do? And For a sort, we just elect no activity. None of these categories
and none of the semplate, no activity. I don't
need anything. I just created from zero. Next. In the next
page, we have name. For example, we say
calculator for our project. We have this package name. And as we say, it's a
unique postal code, you can consider for a house. If you have a house, it
has a unique postal code, and in package name, you have a unique name like domain for
sites for your app. People can make a difference between your app
and the other app. This is very helpful when you want to put your
app inside Google play. It's usually three
part as you can see, or it can be four part. Like this, but it
has a few roots. For example, if I just clean. I said, the package must have
at least one dot separator. And if I put dot says
package segments must be of non zero length because your second
section has nothing. Okay, I say A. The error is gone, but it's
not a good package ne. It's better to have for
example.com and your side name. Follow that. For example, I have 70 20 four.com, and it says a digit cannot be the first character in
a package statement, So I can not start
with the seven. I say site. After that, this is my site 724 le.com. And after that, I say, so what should I do now? I say do my application name, for example, calculator,
for example, news. Maybe I have a news app. I put news. So it's for this
side and this app, and it can be a unique app
and unique package name because I use my own site and my app name inside
this package name. Also, you see, if I press space, you can't use this
space inside this name. Has a few simple rules and tells you what you what you
can and can't do. How about if I put, for example, B W for this news. Is it okay? It gives me no error, but it's most common. It is very more common
to don't do this. I always even if the Andre studio doesn't
give me any error, I always use a small letter and dots just like this my
site and my app name. I never use For example, special characters. You see? It's not allowed. Simple
ame, simple site, and these separated dots
that separates your name. Anyway, save your location, where do you want
to save this app. So as I just showed you, you can open your app later. What is your language? Okay, I use Cut. I can use Job But Google
recommend cutling, and it's more powerful easier. I think it's better. It's my own idea. You can use Java, but most of the
time use Cutling. I think in this year
and the last year, I don't use Java even once. Most of the time cutling. But it's still there and if
you need it, you can use it. From my experience, if you have 100 lines of codes with Java, if you want to do the
same thing with cutline, you have about ten to 20
or maybe 30% less code. As you remember, we say, smaller a, I mean, ranged code function
and lower code. It's better because you can
fix the error more easy. We put minimum etc
on Android seven. You can choose lower, but I don't recommend it. You see, I have even 4.1. Since we have maximum 14, I put minimum seven and
when we have maximum 15, I put minimum eight. Why? Because You see
that operating system. Grows Android operating system
goes for the next level. It gets very new features. And when you select very
low android, for example, if I chose 4.1, my debugging, my error solving
became too complicated. I think I get so much error and nobody almost nobody or a very little people has
this Androids. You see? Just now I put this
Android 790 6% 0.5 of devices will
run my app. Why? Because the rest of the people
have those lower android. It's just a small percent,
but my debugging, my error handling, my
development became much easier. So I will not recommend to
build up for outdated Android. About seven version of
recent Android is good. I think it's default. When I open Android studio, it's default Android seven. I think next year, it becomes Android
eight by default. Why? Because it's recommended, just leave the very, very old versions behind. Believe the last
one recommended, I'm not going to change it. And when I press finish, it creates my a. Okay. Just cancel it. And in the nexto, we continue to see what else can we review and what
points did we miss? So we learned them as well.
49. Day 6: Export Apk And Tips Part3: Export APK and Tips part three. Okay, welcome back. Part three, four, some other tips. Before I start, look, if you press new project, and for example, this one, looking for STCs
available for download. Because we are not connected to the Internet in
previous session, you see there's right for you. This might be old. You should connect to
Internet to check it out. But when you connect
to the Internet, you don't see that anymore. And just checking for
anything changed. And after that, you
have this like this. I just check it out
my previous video and see because I not
connected to the Internet, you see that message. Anyway, cancer, and of course, stable and good
Internet connection. You need that. Another point, For building your project, you need some files from Android Sudio servers
from Google servers. And if you don't have a
good Internet connection, you you don't have them. You might not have them
and then you have error. You have error for no reason. Exactly, because of that, you should check it out. First of all the other thing, you have Internet connection and you have the necessary file. If some of the files are downloaded completely or
broken or any other thing, you can invalidate
your cache and clear your cache and
download them again. And you should also check
these three optional things. So even Andrew the Sudo, do this very cleaner, very deeper, and better. Even you clear your local
history fil system cache. You can check all these three. Of course, if you
have crash for nos then error for no reson and you have a Internet connection. Now, you can do this if Klose and open android
studio isn't enough. Anyway, I just canceled it. Okay, I just open this project. And you see this green check. This green check
means it's okay. So I don't have a problem
because if I have error, as I say, I should fix it. And of course, my
classes have this check. We almost review all
of these things. I don't think much of these
things need to be reviewed. For example, we even talk about the three dots options
and three appearance, Compact medial
package and click on it and you see part by part
your package name like this. These three dots,
three appearance, compact medial package. Change this. Since we talk
about all of these themes. Let me just think what
else do we forgot to say for our ending up
very beginner level. One more thing, I mentioned, if I come and click new
activity empty V activity, I just got an error. Sometimes Andre
Sudo have errors. You can report it. So
Andre Sudo team fix it. I just press the report er. What is the problem? If I right click
on this follar and new and activity,
empty V activity. Nothing happens or
just give me an error. Why? It can be Android Studio. Error? It can be my problem or anything
else. I don't know. Since we are at very
beginner level. We think what should I do? We just check it out. Android test. What is this? Just
double recon it. We didn't create it. So where is our main at
our main activity in here. You see, we didn't know
what just happened. So without going to any detail, we just click in here, right click and in here we
create our MTV activity. I just think maybe these
things happens to you. It can be Andrew studio bog, and it can be your fault. In gar level, don't worry about. An Just learn and
learn. Anyway, click. We have this. I just mentioned another thing. You can choose your
source language. Our language is cul
but you might want to create some of your
activities with Jo. It's okay. You can have your co, your project,
entirely with Katlyn, or entirely with Java. Or with both some
pages, with Katlyn, some pages with Java, it is okay. It's another tip. And you might work with a team. One of your team members
want to work with Java. One of them with Katlyn, I think it's not recommended I don't like to do
that, but. It's okay. Or one more example, you find codes
with Java language on the Internet and you want to use them inside your project. It's okay because And studio
support both of them, some of your classes that you copied or take from
another project or from Internet or from
your colleagues can be Java and your own code
can be Cut It's okay. I just cancel this. One more tip, we run our app
inside our virtual voice. We have another options. For example, we can
connect our own phone with USP cable or Wi
Fi to our computer and do you remember that
debug APK that we create Android studio create that kind of APK and send it
to your phone and run it. And you can see what happens if, for example, an error
occurs on your phone. And I think it's really better because instead of
emulator inside Android, you have it on real device, but we don't check these kind of things in
very beginning level. I just you to know that you can run all of your test
on your real phone. Or even multiple phone, not just one phone. You have maybe one, two, three phone with
Android 11121314, and you want to check on all of four phones to see if
anything goes wrong or not. One important tip. I recommend if you want
to test on a phone, you find phones that has
highest selling number. For your tests. For example, see the market
in your country if you want to release locally
or entire countries to see what kind of
phone and which model has more cells and
you buy that phone. So you can test on the most
devices just like that. I do this, and I recommend it, but you can choose another way. And you even can do this
with two or three phone? For example, find three
more selling phone and test your app
on those three? Or for example, one of them
be a bigger screen tablet, 12 or 13 inch, and two of them be
regular phones. Let me check one more thing. I see. We talk about gradio Yes, I think we talk about it, but do we see version No, we did not. We can change
our app version in here. For example, our version is two. You see pla if you check, you have one app is
version, for example. 20. Next version is 21. Next version is 21.5. And so on you can change
versions in here, and you can name them as well. For example, my version
name is 1.0, 1.1, and my version becomes
two or as I say, my virgin name is 10.0, and my virgin code
is, for example, 20. And my next version is 21, but I just make a
little difference. 10.1. First number
is for pig changes. We don't change that a lot. For small changes, we change
the number after that. For example, one or became two. I think we should specify video ten or 20 minutes just for
how can we add our versions. Just be careful. I just mentioned it so I'll be sure you
understand it well. Version code is an integer. What you can't put
point on this. It gives you er.
It's an integer. 21, after that,
what just happened? 21.1? No, 22. Virgin code is for you. Virgin name is the name
that you show to your user. So I just change it
and it's a string. You see, this, and
this, it's a string. So simply you can say, Okay, it's 0.1 now. But if you say 0.1
error, don't do that. And also SDKs and mine SCs
and other things we have, we don't talk about them. Just this two. Remember
one more time. This is integer
201-20-2203, and no dot. This is a string and virgin name is what that you chose to use. Pesto, you see that virgin. This is the string that
you see in peleas. As you remember, when we
change anything, we should s. Why? Let me just minimize
this Because gradle files have changed
since last project. So it's better you sync your project every
time you change, and we don't change
gradle too much. This is important
file. Be careful. Since as I say, you beginner
very beginner level, please don't change the things that you don't know
what are those. For now, stick to these
things I just said, but not too much. For example, you can't
just change it 1-2. It's ok, change it to two and the version 1.2 became
1.1. It's okay. Okay. Let's just press
thing now waiting. You see if I click on this, it shows me this
background task. Okay. So it's finished successfully. Let me just close it and open and activity main to see what do we have
in our activity main? I have this design view. I can see my activity as near
as can to the user view. And I also have this split, and I also have this code. Let me just check them. Split. I have my code and
my view design mode. Code and design. Now, code just code again, spilt code and design
and design just design. Do you see this palette? We have some categories, common the most common objects, text, ben, rigid layouts. Do you remember? We linear layout, WordCd,
we linear layout, horizontal containers,
helpers, Google, Map view event, and the others. So let me see butten. We add boten. Of course, we use material, but Simply, if we're on design, and we want to add button, we can grab this, take it, take it, take it, release it. We have our button. And since we are in constraint
layout, what should we do? You see the error
open this error. Long story short, it says, you should connect
this to soware. For example, to here. And connect this in here. For example, these two
here, error is gone. Why? Because in? Constraint layout, you should specify how my object will be shown on
the other side, of course. You see two side, I have to connect two
side to remove my error. But it's optional. I add my third side. I even can connect this to
here to here or even to here. This related to this as
I connected to them. And if I look at the split, my object is in here. Constraint bottom to top half constraint n to end of
start to start off. If I remove one of them, for example, this That
line is gone now. The other three, as
you can see, one, two, three, the other
three will remains. So even I have this
yellow under line, let me just press
control z to have my four lines that
are connected. Okay. What does it say? I say, please put this string, the button string into string resource
because it's better. In the future in
the future courses, we try to lower these kind of
warnings as much as we can. But for now, don't worry
about this as well. As you remember,
I recommend that you write these codes
as much as you can. Of course, you can go
to design mode and see these to understand what do you have and
what's their name. And even add them. When you add them,
you can see the code. But I think it's better. I recommend it's better to write the code for each object. I know it's easier
to use design. Because I just drag and up. But I believe it's better that you practice to use as
much as you can the code. This is my recommend. One more thing as I
see this code view, I think I didn't mention. This is with ema language. We write the full view
with Mel language. Exemal language have
this eMel at the first. I just want you to know. This is ema language, and the whole structure of
our view is on emer language. Back to the button, There is our button.
This is our button and view. What else do we have? We have attributes as well. You see in here attributes. Attribute for what,
for this button. As you remember, we
just write code. Why? Because it's better. But if we don't remember or just want to
learn some of these things, we can in attribute
and use some of that. And then write them in code. For example, I want these
to be a little down, down, down like here, 89 90%, for example. You see my hands are shaking. I can't put in 90. It's 87%. Why? Because it's
small and For example, my hand is shaking. And the other 144
horizontal and, let me just go to split. I have 87%. In vertical, 87%, I have it. Change it to 90. My hand isn't shake
in here. You see? Why? Because this is really a
small place I move my hand. But in here, I just don't have that kind of
problem, because I write. If I can't reach teams and
I want to be more specific, more professional,
I use this code. But for a start in the
beginning, as I say, it's came here and say, Okay, put it on the right, 100%. If I want 99%, I can go here and I say
1.0, no, 0.99, 99%. Go back, I have 99%. As you can see, I have
this common at tribute. At the beginning, and
I have all attributes. Most common at the top. Common. Later on, these and all
attributes down here. You see? If I click on it, I have all of these attributes. If I want to find something, I came here, find it. But most of the time
I try to use code. I hope I doesn't explain
too because I just want you to know how important
is to write with code. Okay, let's close the video, but just one more thing. Let me just because I open this. I just show you
if I go to split, I can just take it in here and right click or
open attribute. I have this margin
that moves it, and I just can open
this and remove it. I I type anything wrong, And also, if we just go up. You see, I just connect this
to here and I can press in this x pattern or
just remove it in code or press this
x, just removed. So we can D this but left Android
doesn't connect anywhere. We have this error. I can't move it up and down. You see, I can't move
it to left Android. Why? Even If we connect this in here, I can move it left and right, because I should first connect the left
side to somewhere, then because my left and right connected to
somewhere, I can move it. I mentioned this
because if you came and see you don't
have those buttons, don't worry this button. You see, I select it, but I can't select it in there. I just came to code to
have access to my button. I click it, click, click, click, lick, click, click. I can access it. Why? Because in design view, sometimes these kind
of things happen. If you have the same problem, click, click, click,
you can't have it. So simply split or even
code, click on it. Now you select it because
you're on that button. Now, came back to design. You have this in here and you can change it because
you now select it. Sometimes even Andrew the studio have bog and because of that, you can simply do anything
you want in code. It's most of the time
better than design. But in design, as you
can see, I have manyth, and I can change these
things simply and fast and see what just
happened in the second. So, we should combine
these two things. But most of the
time I go to code. Thank you, and I see
you in next video.
50. Day 6: Export Apk And Tips Part4: Export APK and tips part four. Where we we. We just show you the design mode and we talk about these objects. Do we have anything
else? Yes, of course. You see here component, come here and click on this. What do you have in here? You have your constraint layout. Under that, each
of your objects. If you click on any of
them, you selected. Inner layout, BTN ad, Bt BT BTN, TX V tX
result and the button. What is this button?
This button, the last button that we add. So we have them like a tree. Why? What does
that mean by tree? It means since this
DTI first value is inside that
input layout first, it's a little to their right. You see, and if we close this, We don't see that
or linear layout. Inside this linear layout, we have four buttons. These four buttons, if Kels it, T view is like this and
open it Kelst pen it. Let me show you, project, you have these three view, Kels open, Klos open. Just like that, you have these three view as
well, Kels open. Okay, What's next? We have some things
up on this place. Let me just minimize this and minimize this and what
do we have in here? I have device for preview, which device do you want? You can't have your
preview on TV. You can have your
preview on watches, Smartwatches, and the
other you see Even cars, what else I have? This button? What does it say? System I mode? Let me just press on
it. What do I have? Not night. Not night means normal view. Most of the phones
are on normal view. But sometimes your
phone is on night view. On night view, you
have darker colors. So your eyes get be
more comfortable. Let me just show you night view. In night view, your
app is look like this. So you can check it out. Can you see things
on night view? Can you read numbers, read the buttons on night view. Is everything okay
on night view? Just remember, it's better to debug and check your app
on night view as well. Let's back not night. What do we have orientation? What do we see is portrayed and we also have
landscape. What is it? It's just look like you put
your phone on the side. Of course, you can lock
your app on the settings, so your app doesn't
move on this side. Don't be like this. But if
you want to be like this, you should divide it
in this mode as well, but most of the time, I personally just
lock it on this view. What else design. Surface, I have the design. But it also gives me forget about all
of the other things. Let me just show you blueprint. This is blue print. You see, and I also can see design and blueprint
at the same time. You see how helpful it is. But usually, I set
it just on design, and sometimes I put it on
blue design and blue print, and then I put it
back on design. Do we have anything that we should check it out on
very beginner level? Yes, for example, we can just
look at these guidelines, click on it, vertical guideline. L et me just add one. I add this guideline, move it until here to check, is this with this with
that are age or not. It helps me to see
what object is there. Most of the time I
use it for this. It has many other thing to do. But most of the time
I use it for this. Maybe we talk about the
other things that it can do, and of course, the
others in the future, but for now, How
can I remove it? This is the point. I I
bring you here to say, How can I remove it now? I do whatever. Even if I close Andrew studio and come
back. It's still here. Oh, no, what should we do? You just see go to
a split or code. And see. This is an object. It's not a invisible line. It's really an object. So you just select
it and delete it. It's a really important point. I think you beginner level might found it really
helpful. Okay. What else you see this? This is really
interesting as well. Click in here. Show
all constraints. Look at the page
and click on it. You see now we see these
connections, what to what? If I check on check it
and we have none of them. And also not love. We can check system UI. Yes, we can check system UI. If you check this system UI, you have this clog
and battery and other thing on the
top like real foam. It can be helpful.
It's up to you. I usually just check it. Nothing really important
in here. What else? And attribute, let me just show you one thing
about attributes. You see, we just talk
about these attributes. There's a lot of
attributes in here, and there's a lot
of menu in here. I can't talk about
all of these things. But I just show you an example. Attributes, you have visibility. For example, look
at this button. If you put this visibility
and click on this drop down. You see you have three options. For example, if I say invisible, this isn't visible anymore. If I say visible, I see it. I I select this text and
delete it by default, the visibility is visible. It came back to default, and I have so many other
options and attributes. We talk about them
in the future. And let me see anything else. We can just wrap it up to day
and go to beginner level. Oh, one more thing. Let me
just show you this as well. You see, we have this.it
first value dot. What is this dot? This dot shows you the thing that has the
property that has or the function that has inside an object or a variable or any other thing that
you put this dot after. For example, this
DT fverse value has a property of error or simple example,
more simple example. We have this tx result dot text. So our tx results have
a property named text, and also they have
property name visibility, You see, you have all the
other attributes in here. You see this, you see, text button, you
change this text. You change this text. Let me just show you.
Ck in here, press dot. Nothing shows control
space. Finally, it shows. I have text I have error. I have functions like to string. I have hint and
many, many things. I press V. I have visibility. I can change it in here. And of course, as you see, we have very many other things. Because of that, I press V. So it just shows me the things that have V
and, as you can see, it shows me the things
from the start first, one, two, three, four,
five, six, seven, eight, T, that has at the first. Other things that have, for example, that
has, for example, in the middle or after these and if I want
to change visibility, I I should choose this and
equals anything I want. Anywhere I want. For example, after an ease. If something happens, my
button became invisible or another of my buttons
became visible just like that. I think it's enough for
very beginner level. Let's go to beginner level. We start with a project
and we hope you enjoy it. I try to teach you
as much as I can. Since I have teach
this much experience, I hope I can teach you
well and you learn a lot. Please, if you have any idea for making
this course better, Give me a message and
give me your ideas. These ideas, your
comments, your reviews. All of these things are very, very valuable to me and
has a lot of value for me. Thank you. Before I end this delete this and press delete on this because I want to put
the source for you as well. Thank you.
51. Day 7: Game Intro: Game intro. We want to create
a game like this. Just like our simple calculator that we do together and
learn a lot of things, we want to do this together. So first, we want to
plan our project. So what is my
project description? And for example, how many pages does this project
has and each page. What does each page has inside? And even what does each
part in every page does? I should specify all of this. Then I can start. So let's start. My game has one page. This is my game page. This is my guessing number game. User in tres a number in here and a number in
here in this box, and then tres a start. I also want this and this
and this to be hidden. What does that mean? It means invisible doesn't
show by default. The user can only see first
and second box and the start. And of course, the
report and the result. Just when the user
press a start, this and this became visible. The user. Put number one inside here, number two inside here, press start and this shows and system inside here
inside our coding, decide a number
between this and this. Then these shows the user. Then the user, when this
and this became visible. Inter the number. Press go a number
between this and this that the user
already enters entered. Since the system, our code, our program decide a number
between this and this, when a user enters the number and press
go system checks does this number is lower bigger or equal the number generated
between this and this. Then the system tells
into the result is the number equal is
it bigger or lower? Is it equal UN. Anyway, I have report
button as well. When I press this report button, the system shows all guesses that user make inside
here and make it visible. For example, if I put inside here ten and in here 100 system, decide the number between them. For example, 50. And I say, Is it 70? The results say lower, I say 60. I say lower, I say
30, I say bigger. And if I say report, if I click and report, I can see What are my choices, my history of choices? History of guesses, sorry. This is my whole project, and we want to learn so
many things by doing this. Our goal is not to finish our
project as fast as we can. Our goal is learn
as more as we can. Okay, I just press open, and since I want to
open from the seven, I choose my project, and then press Okay. You see the green thing. It's because this
is Android project. I'm waiting. My project builds successfully. If I go in here and
you see this bill, click on it, it said Built successfully
in 30 seconds. And of course, if my
project needs anything, it downloads it as well. For example, any missing library or may be a library that needs
update from the Internet. Minimize this, minimize this, and go to our code. As you can see, we
are continued to make this project inside our
calculator because in this way, we learn a few more things. How do we do that? We just inside this activity
man add a button, just under these four buttons. And if the user click
on that button, it takes us to the game page. So how do we do that? Let's open this
project. Open this app. Careful. If this
Android be on project, you might get confused. So it should be on Android. I have this cutlin
plus Java. I open it. I open my package name. I have my main activity in here. This is my cutlin fight. First, just let me
show you the button. I think we can learn a few
point and tips in there. For example, I want
to add my button, but I can't add it
in my linear y. I just select one of them. I'm here. This is my linear. For example, if I just copy this control C and
er in here, control, I have this extra plus and change the name at
one at the end, so I don't have any error. You see, all of
the five buttons, sit together in one line. Why? Because it's linear layout. If I add even five more buttons, it tries to put them in one line just like
this. I don't want it. I want my button down here. And the big button, I want big button for
entering my game. Let me just change
this name to Ga. Now, I have BTN game. As I say, they can't be on top of each other and
they are like a line. Linear layout is
horizontal or vertical. If if it is vertical, they from here, go
to down like a line. Even in that case, they are not on
top of each other. Just like that, they
sit side by side. So you can't add one extra
button down here. It's a line. You can even have your
parent layout linear layout. Just like this, I just
copy this linear layout. You see this one
constraint layout. If you just change it to. Linear layout. It
gives you error, I have error. What is the error? You should say, what
is your orientation? Vertical, horizontal. I just want to use this copy, horizontal or not vertical
because we want to be upside from top
to down vertical. Yes. We have this after
that, this, this, after that, this on
they're each other. And none of them in
on top the other. Even when we say horizontal, you see they're out. Let me just put
my mouse on here. You see on the
right, they're out. Why? Because they can't be
on top of each other. Anyway, just control
Z, control Z. B, back, back. I change it back. Constraint layout. Okay, my BTN game. Okay. Let me just minimize this, minimize this and the others. I just minimize all of
them and copy this button. I want this button. Control X. Because I want to put it
outside of this linear layout. So, Then minimize this
linear layout. Where should we put it in here. Or we can just go here. Another inter and control. You see it shows it
to top left and gives you error because it says you didn't connect
it to anywhere. These four circles are white. You should connect
them to somewhere. This is constraint layout. You should connect
these white circles at them at least two of them, one, de side, one
de side at least. Why I just put it down
here to show you. You see, it's here. If I just control x and put
it here instead control. Is there any difference? No. Because there's no
matter where you put this object
here here or here. It's top left until
you tell your object, where should be connected
the object size. We should the object
sides to be connected to it doesn't matter where and
how is our orientation. It just shows
everything that you don't specify where
to show top left. But it doesn't in linear lay. You see in linear
lay let me just show you This is our minus. This is our division. If I control X cut this
division and control V, our division now is
before our minus. And again, control x, put it back because
in linear layout. First, you don't specify where
these buttons are shown, they shown by their orientation. How you sort them. First object shows
first first object, second object, third
object, forth object. This is linear layout. But in constraint,
doesn't matter. You should connect and
specify how it showed. Oh, this is constraint layout. Let me just connect from view the upper circle to down
of this linear layout. I still have my arrow. Why? Because I should specify left or right of my object as well. To be connected to what. So you see the code, just add my code layout constraint top to bottom
off, linear layout. Let me just write the
code for the next one. So start to start of a start of what
ID linear layout. So my left is where
the linear layout left is connected to
that and my top is connected to the bottom
of that linear layout. I click in here and I
have no arrow. Why? Because I say my
horizontal and my vertical at least one point in each of them connect to where. Press press press inter in here. Let me just say n to end to end of and press in linear layout
as well, and remove this. You see, it's even faster. When you get used to typing, sometimes it even faster than
you want to connect them in here and easier because I have more control
and more specific. Now, simply STR ad, we change it to STR game. We don't have any STR
game. What should we do? We can't press and inter
or just this light bale, say, we want to
create this string. We just copy all of this, and we just click in here. Create for Arabic as well. I simply write game and I press. Now I have my game button, as you can see, let
me just this hand, you can move it by this
hand with this button, um fit screen, and with
this button 100%, and. Anyway, We just a
little you mean, why? Because I want to show
you with this hand, this is game, my game button. Now, where is it
this string project, resources, values,
strings, my English, default and Arabic string. English, this game Arabic. We can translate
this Arabic as well. Let me just minimize
this low this lose this and Zoom to fit screen. We have weight. This is for linear layout, but we're not in linear layout. We just copy all
of these things. So remove this. So
it's wrap content. What does wrap content mean? Means, take space as
much as you need. As as you can see, it writes, the view should be only big enough to enclose its content. Of course, plus adding. This is my wrap content,
just this size. This size. But what
as we talk about? I say zero d p, takes from left to right. This zero dP works when we have constraint layout
on as our parent. Layer, as we can see, we have constraint layout, so we can give zero DP. So we connect left and right. What if end to end
of be removed? It doesn't work anymore. You have zero DP
and it works only if left and right are connected, and the left control
X doesn't work, only works then left and
right are connected. Let me just show you
in our text view. This is our text view, open this and we have zero DP
and talk about it in here. If I say wrap content? It's too small,
sticks to our data. If I say match
parent, it's too big. It goes on our view. You see, it's on our
text view. It's too big. How can I have perfect
size zero d p. I have no interfere
with my text view. I minimize this as well. Anyway, my button. Just one more thing,
did I say the numbers? If I say, for example, instead of zero DP. 100 DP. You see fixed
size, but not good. How about 200 DP two B 2202 B to a small 20 DP to a small. You see, I can't decide
what should I do? But zero DP is perfect. Just for you know, you
have this zero for it. But as I say, you should connect if you
want to use for height, Top and bottom
circle to somewhere, then you can use zero DP. And when you use zero DP, it means connect to
the left and right. And for head, connect
to the top and bottom. As you can see, I
have mistake because this view is under
this text view. Because of that, I just
cut this and put it here. Because as we talk about,
in constraint layout, it doesn't matter the
order of these buttons, because these connect
to each other by constraint start or
end and the others. It's better I order
these as I see them. For example, this before that, these and before that this. Of course, before
them, my button. If not, I could be confused, we have our button. We want to write code, Because we want to do something when we
click on our button. I go after PT and in
here, press inter. I write Bt N. I have
five button now, because I add TTN game. If I click on BTN game, what is click But set unclick listener and in
here, just like this. Now, I can write
my codes in here. I select wrong thing, but let me just show you. If you select the other
unclick listener. For example, the first one, you simply remove the
extra thing and add this. Why? Because we don't
want to give this any parameter at the
moment for this code. As you can see, you might have different set on click listener, because we can
choose between them. Anyway, if you select
the other one, simply, for example,
this one, sorry, for example, this one, you simply remove
this and add this. We shift and nine, and then if it doesn't
add the closing part, shift and zero on your keyboard. And do you remember since
we write this apply, we don't have to say binding que mark D PTN game and another question
mark and the other. We easily write PTN game. Even, we don't have to write question marking
here, simply easily. And also, I think you
remember find view by ID that we should write many
codes to find our object. But we don't want to write
that in here as well. We just use our PTN name. So if you there, click on this button, I want to open our another
page, another view. We do that in next video. So we don't make this
video too long. Thank you.
52. Day 7: Game Page: Game page. As we talk about, we need a page like this, and in previous video, we just talk each part do what? Okay Let's continue.
Open project. We have this in here. If you see this part by part, just click this option, click this options
three appearance, compact middle
packages, like this, or like this, like
this, or like this. We keep it checked. So click, we have this in here. Right click in here, new what, new activity, what kind of activity? Empty views activity, see
the pad or just move. Don't do anything
with the others. Just go to activity. Okay, click empty view activity. We have this page that helps
us create our new activity. What if I remove this number two and give this main activity, I said activity name
must be unique. You already have
this main activity. You can't have two
main activity. Let's choose different name. For example, game activity. As you can see, I put upper
case letter for start my each w. And as I already
told if I press space, it gives me error, so no space. Since it already checks
generate a layout file, and if true a layout
file will be generated, O layout name comes
based on our activity. And most of the time I leave it like this because
it makes sense. Let me try that in here as well. Space gives me
error, so no Space. Is it my default activity? I mean, if I run the app, this activity is the main
activity, no, it's not. So I don't check this
launcher activity. Of course, I'm not going
to change my package name, and my language remains cutlin because we're going to teach
cutlin in this course. What now you see this
finish, press this finish. Now we have our new game
activity, our new activity. What do we have in layout
activity underlying game? Minimize this and
we have it in here. Anyway, I just
comment these lines. What do we want?
We want to go in main activity on BTN game. And when we click
on this BTN game, it takes us to our
game activity that view called activity game ML. I write start activity.
Start activity. It needs input. We talk about input
in functions. So we should give this an input. What kind of input? It needs intent. So if you go on this and press control and press your
left click, you see this. You have two kind
of input in here. You can just put intent, and you also can put another thing after
that intent. Anyway. I just say for more information. If you want to see how
many options do you have? Go on that thing. Press control and click and see how many declaration do
you have for this method. So, let's complete this command. Go here and write in ten
application context, and just the button write to the M game activity class,
Java don't remember. Don't forget that dot. Let me explain very simply. Pay attention, pay attention. With intent, I say, what do I want to do? This start activity can
do many kind of things. But I want to say
what I want to do. Long as story short intent helps me communicate between
different components. In many ways in my program, and it does many
different things, so I don't want to
make it complicate. So let's just use this
intent to navigate among different activities
within our application. We want to know this kind
of use of intent for now. Our first parameter
takes context. Let's just not talk about the context and just select this and write this at
sign main activity. Our main activity to go
where game activity. Don't forget about
this separator. It's just next to M. If I
remove this Java control X, it gives me error not ok. If I remove Ks, it gives me error not ok.
Just write like this. Even if you forgot
about one of these, it gives you error. To write this, you
should press shift and the button write to
the, just like that. So, for example, these
parts are fixed. If I have another
page, for example, login activity, we want
to go to for example, we have login activity. What should we write in here? Easily. You see this cutline? The name of our cutlin code, we write it in here. No activity underlying game, no, no, no. Our cutline fine. Our cutl file game
activity game activity this part is fixed, but this is the
name of our cutline file the second part and the
first p and the first part, as we say, take a
context from you. Application context. All activities has an
application context. For example, our main activity, even our game activity and all the other activities that
we might build has this. Let me hide this. They all have application
context, all of them. That is my context. What is context? Don't worry about it for now. But if I want to make
it as simple as I can. It's very beginner level and
I try to be simple as I can. This application
context has some data has some data inside from
this application task, and even where does
those tasks came from. And even the options, no the configurations
of those tasks. So lots of these data for our application is in
this application context. It's some kind of variable. Okay, let me just tell you, this is a variable that
has some data inside. From our application task, and the information
of those tasks. For example, configuration
and history of those tasks. Yes, it's really better. Long story short, this application
context is a variable. It has a set of data and
this data for our tasks, and even our tasks, histories, let me
just clean this. But as I say, you
don't have to know just you should know
that your intent, where is our intent here? Our intent needs a context. So we give this intent,
our application context. Just like that, And remember, we have a lot of other
things with this context. We use it many ways many
times and many other places. So don't worry. We use a lot and you
get familiar with this. For a star and for now. Any function that
needs a context, it's easier because most
of the time it's okay. We give it application context. You can write these
things somewhere or simply we see lots of these things in future
videos and you understand. Application context
is for this activity. So we want to change
it instead of say application context
because we want to say, this activity, let me just say this at sign main activity. What is main activity? This is main activity. So I mean this activity, take this main activity. Take this activity,
whatever these things name. This, main activity. And don't forget this at sign. At sin shift and number two on your
keyboard at the same time, first press shift,
then number two. Sorry if some of these
things you already know, I just really, really want
you to learn very well. This is really important. You should learn very well. Okay. So let me explain more. What does it say when
when I write this? This means this. It's English word. This
means this. This what? This, this thing, this
thing I've just in. Okay, what do you
want from this? I want main activity from this. So I mean this main activity. The exact words in English. From this main
activity that I mean, I want to go to go where? I want to go to game activity. Here, game activity. You know why I explained this much because these kind
of teams are the teams, my students ask in classes. Ask what do you mean by this? I mean simply from this
activity, go to this activity. This is my activity
that I'm already in. Let me review.
That's a long video. We repeat this many times. We want to do something. We want start activity, and we say we have this intent to say
what do we want to do? As we say, we use this intent to navigate between activities
in same application. Okay, from what activity, this main activity to what
activity to game activity, As we say, we can give
this application context, and application context,
give this exactly this. Because application context
in this contains this. These are same thing. Don't get it wrong. Finally, we just write one line. Let's go and see what
did we do, Rn Dia. Okay, my project is up, and this is my calculator
and first number, second number, my game button. If I click on this game button, this BTN game set
click listener runs. So I click in here. And I move to another page
because I start activity. What activity from
where to where? From where to where. Okay. Let
me just call it from where to where from where to where from main activity
to game activity. It's better. I shouldn't
describe this. I can't these things for
now with simple mes. Start another activity,
go from where to where from main activity
to game activity. Easy PZ. Okay? This is my new activity, my game activity, and of course, activity underlying
game that XML. This is that. No cuting. You can't see that cutlin code. You can see this XML code. They are different.
This is what you see. This is the things that program do for you
when you do something. The reactions. Yes, let me call this cut lin code reactions or things that you want
to do and react. Yes, reactions. Why not? Let me just press this back. You see this. And
again, you see this. Okay, finish stop
and minimize this. And let's go in here. Split this. Let's just continue
this in the next video. I think this video
became too long. Sorry for explaining too much. I tried to solve any question that you might
have on your mind. Thank you.
53. Day 7: Arrange Game Page Objects: Arrange game page. It's now 0.4 create this page. We have all of these objects that we talk about
in previous video. Now we want to create them. Previous video in activity
main we click on game, and we came to this page. But this is empty. So how can we feel this? We need to input, first number, second number, so the user
can input those numbers. We just go to activity main. We have this, and we
have this as well. Let me just change the
gravity from start to center. So they look like the same. Let me just copy this style as well from the
second one in first one pasted and remove
the extra empty lines. So And I just copy this style from the second
one in there as well. So they look look
like just the same. They're similar now. Now, I just close kilos, kilos, and let's just copy this. Control C, and in here, activity game inter control, and remove this comment
that we just bring with us. I have these two edit text. I just copy this, but you can also type them. By because it's
better for learning that you type and you give
each of these properties. It's a good practice. Please type these things
as much as you can. So you can learn what are these. As I told you, you should
write them as much as you can. But For not waste
time of teaching, I just select this button. This is my button and control C, control V, and of
course, minimize this. Since I just copy, it gives me error, y because it doesn't have
any linear layout in here. So what is this button? It's PTN start, and I also
change the text to start. As you can see, I
don't have any start. So press inter or
press this light b, create a stream value
for this resource. Check Arabic as well because
I have two languages. What is our value? Start. I press. So of course, since I
don't have linear layout, I should say This
is my second input. I want this ID input
layout second. I just copy that,
but you can type it instead of this linear layer. This linear layer,
I just paste it. Of course, top two
bottom of what, I don't have linear layer, so input layout second. Even when you learn a lot, sometimes it's better to type, so you don't forget things. From the left, connect to the left of this,
from the right, connect to right of these, and from the top, connect to bottom of this. You see after start button, we have a box as well. So we just copy
this like this and go to the end in there
and paste it there. Have error, what does it say? Our name is problem. Input layout, what
should I call it? We intern number in here. Let's just say guess, because user guess the number, and of course, DT, Yes. Do you see this light pub? If I go in here, the light pub gone. Sometimes we have a few errors, but they might be
Andrew Studio put. For example, if I
click somewhere else, the errors will be gone. It happens. And it's okay. Each new version of Andrei Studio came and the
bugs became less and less. And of course, I
had this PTN start and where should it be
end to end of my button, start to start of my button and top two top to top of my button. But as you can see, if I say
top to top of my button, my text box and my button
b to top of each other. Top of this equals to
top of that button. So I think we should change it. Let me just say to bottom up. And if these kind
of things happen, you can just select from here to here to
remove extra part. So top of this object to
bottom of the object, I just say top of this
to bottom of this. Anything else, let
me just say int? Oh, I just have hint. First number, no, no, no. Let me just change this as well. SC R. Your guess. So a so guess, I don't have a SRO guess. Let's just create it
and in Arabic as well. Let's just write your guess. Well, let me just show you, we have the strings. Just check. Ast your guess game and Arabic game asst your
guess. We have this. Klose that, Klose that, minimize this. What's next? We have this button,
this report. Let's continue. So
next is our button. This pattern, we just copy
this and at the end of this. I just paste it. Of
course, it's PTN. For example, go is a good name, I think, and text, it's not a start anymore. CR go. Now I don't have it, so
let's just create it. Go and not forget to
check this bic and. So it's on the top
of the other button. We should it be? I have this
input layout gas, control C, and change this toput layout guess to a stat of and to end of input layout gas and top to bottom of
input layout gues. So my go button is now in here. And let me just show you if I write EDT guess, what happened? Control C, If I say EDT gas, it gives me error
because I can't do that. I should control C,
input layout guess. Because we don't
have any EDT gas. We just have input layout
guess for connecting these. See if I select EDT gears, it doesn't have
that white circles. You see, but the other
one has that circles. It can connect to
connect to something, but this one cannot
connect to anything. So long a storage short, our digest are inside
another object. Because of that, we
can't access it, and you can give your top
to bottom of to end of and the other thing based
on the things that are inside your
constraint layout. Not on the other things. So I can give Input layout second. Because it inside our
constraint layout. But if it's on the other thing
like this DT second value, I can't do that anymore. Anyway, as I say, you can't
see that error anymore, why? Because it takes time to go
from there and you can click somewhere else and
came back and you can see even it's not
in the left anymore. Before the middle part, I remember we have the
result on the bottom, and we also create
the result in here. So let's just copy this. Minimize this, minimize this, and of course, this view
this this and this. I just copy control
C of this te. You please type as
much as you can, but I'm not in here, so you don't waste control V. We have the in here now. Okay. What's left? This report and this button. Okay I here. Let's just type this
one and the card view. I just write CA and I
select this card view. Just check again. Android X card view
Widgit card view. Okay. It's okay. I just select Match patent. It's on that by default, and of course, wrap content. It gives me error because it
doesn't connect to anywhere. But first, I should close this. Okay. Shift and the
button right to the M, and a slash that is next to shift on your down right
the buttons of keyboard, left to the shift button, I just press it, and it writes the rest for me. I go start of this
and inter inter. I close this. I just forgot. I don't close this. Shift and bigger. I writes that for me
without any more thing, I should remove this
and inher inter. So now top, not in here, but in here top to bottom of to
bottom of B and go. Let me just do this again. I just write constraint
top to bottom off. For that, I just write bottom off and it
gives me the four. I press inter on the first one, press J, and I have
BTN like this. And if I want to show you again, I don't remember that. You see? I I just want to show you again, how to write that to
of I don't have it. Why I don't have that? Because I just write it. But if I don't write it, I can't find it. And G BT. Understand, if you
write it already, you can't find it,
it misleads you. You get confused
because I want to show you and I can't find
it, I got confused. Because in normal programming, I shouldn't write it many times. Start to start of what. For example, P parent. Press P and then
patent, and of course, end to end of end to end
of what parent again. Let's give it a margin as well. In here, margin, that sign g. Since we call it
normal margin in here, I just should say normal margin. I just check the name. Give it normal margin. If you get different names
in different projects, you might get confused
like just I do. This is another tip as well. In card view, you can
only put one child layer. So we just go in here. So I put a parent layer. Let me just show you. For example, I just write CO N, and the first one is
constraint layout and match parent
and rack content, and just close it as well and
inter and click in here in inter mean height
for example, 200 DP. I just give this card
view card max elevation. And I just say I clear this and write enough ation, and I don't have it. So give it eight, if you forgot to
put DP after that, you see, you just put eight. You came in here and put DP. This is a common
message as well. Can minimize this, came back. Now it has eight DP. Now, just press inter and A, and give it radius. I just press inter and D. So I can give it i radius, I think, and it doesn't have it. And create this one as well. A. We don't forget to put DP. If we do, we go and
put it in there. We have this ADP as well. You see my error isn't gone. But if I click in here
and then it came again, my error isn't there. It's a simple bog. Don't worry about these
kind of bogs. It's okay. Now, let's run our app. Okay, we run this in 7 seconds, hide this and press game button. We have this page. Let me zoom in. You see our first
number, second number, our start button, your guess and Go button, and this carviw. I don't think you see
clearly my car view. Let me just stop my app and minimize this
to show you better. First, I should give a
background at the top in here. For example, in here, I
just say background Black. I think you see it better. We just say background, Black, so you can see my card
view and just want to I just want to
change this radio. So you can see what is it? Control X, what is better way to learn than
see what just happened. For example, 50
DP, or even more. You see the corners, I give this more 90. You see our corner be like this. Let's put it back. Control we put it back. If we don't give
it this Control X, it's very sharp on the corner
in 90 degrees and pointy. Because of that, we
just give it eight d p. Let's go and clear the
background as well. Remove this back. Now you see our card view. We can use material card view. Like button and other things, it has more tools and
options and possibilities. And Android Studio and Google
itself brings that for us. So, I just write card view. And instead of that
card view, I go down. And second one, I have material card
view, as you can see, and Android studio itself, put this material card view
closing part in here as well. It is really good and
makes my work easy. Because if not, I should come down here and change it as well. As we already say, if we have material
for the object, we try to use material
for that object. But I just want to show you
regular object as well. Anyway, card view as we
told gives us a box, a place, this much, for example, You see, we need little space. For example, this much
space for our report. Because of that, we
add our card view. And we add material because it can be more beautiful
and has more things. So I just go down. I have my text view taxis, yes. I just copy this text view. Control C and put it on my constraint layout
inside my card view. Let me just open it. I want to say top
to top of parent, of course, and of course, end to end of parent, and start to start off my
parent, a little delete. And sory patent patent. That's right. Now,
it's look like this. I don't want to
use tools in here. I want to give this and tax. Because I don't want tools now. Because as we already
talked about, tools is for me the programmer. Now, high the string, remove it, control space. I want to put a string. Name. No, Of course
not. Of course not. I just press inter, so I have at sign string
Slash and I remove this part and say STR underline report. But it doesn't recognize
any SCR report. Let's create one and check
as well, and report, and. Now, it says report,
and of course, our IDs report labor. It's our name, our
name of object. We can access to this object
with this ID with this name. And not zero dP. Just trap content. It's okay. And one more thing,
I need a button. This go button. Let me just copy
this and take it here and change the name to BTN. Report, and of course, STR. Report. I want to say
top to bottom up, but I need to give this an ID. You see? I don't have ID. So I can't give the other object this thing's
address, this thing's name. So what should I do? ID? What is the ID? Of course, it's a card, so card. It's for report. So card report,
and let's go down. In here, top to bottom off. What card report, constrain
top to bottom off, Card report, and this
zero DP rack content. O let me just have that zero DP. It's okay. I think it's
enough for this video. We continue on next video.
54. Day 7: Other Changes In View: Other changes in view. Okay, what do we have? We want all of these things and also we want these
three be hidden. Welcome back. Let's grab this a little down. We just go back to this
material card view. We talk about this radio. I did this wrong. I shouldn't use Max elevation. I should use card
just elevation. Why? Because I want my shadow. You see this shadow.
I just click up there to unselected and
you see the shadow. Because I write Mx elevation, I write that wrong and I
don't get that shadow. Let's run the app. I just
click the game button. Okay. And you see the shadow. Let me just zoom in more. You see the shadow, if you
run write any other property, as well, you might not
get the good result. This is another point. Let me just stop this
up and go back to ding to see what if I give
more than this eight. For example, control
X, for example, 40. You see how much more shadow
I have or 20 DP or ten DP. You can see the difference
or even one DP. The shadow is gone,
almost gone, ten DP. I put it down so I can show you. But you understand the point. Anyway, I just control
re pat it back. You see most of the time I use some predefined
number on my mind. For example, four,
eight, 16, 24. For example, this is eight. If I want less, I put four. If I want more, I put 16. It's on my mind it's on
my mind and it's my rule. You can set another rule. For example, you can say five, ten, and 20. It's on yours. But it's better to use the same number all
around the project. As you can see, if I open this project and show
you the diamonds. Even in this seven,
put it 88888. If I want to give other things, I say 16 or four or 24, I say specific numbers. So all time other teams
have almost the same range. For example, for a
small, I put four, for big, I put a
specific number. And for each project, sometimes I write it down
this specific number. I know these are my range. And as you can see,
most of the time is eight or four or 16. Let me just close it as well. Just for remind you, I just me one to one. This card view only
takes one layer. Inside it, I put this
constraint layout, so I can put many
objects inside. For example, if I put one more object beside
this constraint layout. For example, it takes. Let me just control C, control V. It's not okay. So since I should only put one object inside
this card, you, I put this constraint layout and inside this
constraint layout, I arrange my objects like this
So anyway, let's continue. We have this text view. I came here and press inter
just after this gravity, I say text text story. I have three different choice. See if I say italic, let me just mean so you can
see this better in here. If I say this italic became like this a
little to the right. If I say bold, it looked like
this, became bold. And normal it's just normal. It's better you don't write
because it's already normal. Anyway, I want bold So it looks a little
stronger and bigger. So we make it a little bold, and also I want change the size. So I say text size. You see this text size? It is 14 dP by default. You see 14 d p by default. Let me just control X. Okay. You see, and
then control V. I should just cut whole line. Control X. Control V.
No difference. Why? Because it's default. You can say, for example, 20, it became bigger or
40 really bigger It's up to you how do you
want to this look like what, as I say, if you
give 14 is default. So if you want to be bigger, you should be more than 14. If you want to be smaller, you should put a
number lower than 14. So as I say, I like
to write 48 or 16. So I give if I want to
change it, I give 16. It gives me a warning.
What does it say? It says should use SP instead
of DP for text sizes. Let me just change it to Sp. But what just happened? In Android phones, when
you go to setting, you want to change the sizes. You can make them
bigger or smaller. As you can see, many phones
has this setting in Android. I think almost all of them. If you change this to SP, when use phone setting, change the phone text size, your app, this SP
changes as well. For long story short, with SP, we go with font size
adjustment and setting. For example, if we have
14 and we make it double, we have 14 by default, we make it double,
for example, 28. It's become double of others. When you change the font
size of the whole phone, your Sizes are relatively to the other texts in his or her phone became
bigger or smaller. I hope you understand it well. I hope you know what I'm saying. And long story short, all the text sizes you use
shod be SP, all of them. Of course, it's up to you. You can use DP, but it's better to
use for all of them, SP. One more thing. We have this margin. Yes, it gets a lot from top. I don't like it.
Just from the side. So I change it. I put one horizontal.
Just like this. Let me just select it
and see the right. Now I om it for
you. See the right. I want to press control
X, S the right. This is the difference.
See the right, control. This is the difference. You see? Now, if I want
the normal is like this, and if I want just from
the side, it's like this. It's better, I think. I don't want too much
space from the top. And only spaces from
right hand left. Let me just run the up for you. I press this green
round the button. So let me just see
what just happened. Minimize this and
zoom out. Go to game. Okay, I have this. It's good. It's pretty good.
But one more mt. Do you see any problem in here? Do you remember this? I should hide this, this, and this?
These are hidden. Let me just back to the code. As we see, we should hide
this, this and this. But now we just saw them. They are not hidden. Now, let me just stop this up? And minimize this and oom
out, of course, 100%. And your guess, I have this. Should I write any code in here inside this text input
edit text? Of course not. You see this text input layout. This I click in here
on text input layout. After this lend,
I press in there. I say, Visibility. Just with these three words, visibility, I found visibility.
Which one do you think? Let me explain this for you. Just as I say, you see how fast I
write it even faster than you want to try to
find it in attributes. Let me just check that again. I have visibility
inter, just like that. This much faster. When you became familiar
with different codes, I believe this is
really most of the time faster then work with
this design mode. And also, I have so
much more control. Let me just see what is
these three options. I have visible. Let me just select visible.
What just happened? Nothing, absolutely, nothing
because it's default. By default, my
object is visible. So nothing happens. What else do I have? I have control space. Control X to cut them and control space
to see other thing. I have invisible.
And I have gone. I just want to see
what is this gun. I know invisible, but
what is this gun? My object is just gone. You see the space. There's no reserved space
for that thing. It's gone. It's nothing done. But how about invisible? Let me just look
at that as well. Control X, control space. And I have this
invisible. You can guess. Yes, I have my space, but my object isn't here. You see how good is it?
Control X. I have this. Control V. I don't have this, but the size isn't change. It reserved for my object, and then my object came back. The go button is still here. Why? Because the space reserved. Let me try it gone. So I want to do this
for the button as well. So I just select this
control C, go down. This is my button, and press inter control, and I just select this, delete this extra line. My button is gone as well. Of course, I have this
card view in here. After the margin, I press inter for this card view
and another control view. This is gone as well. Let me just run the app to
see what just happened. Now, let me just minimize
this and press game. You see, I don't
have them anymore. It's good. Now, let me
just stop this and, go back to our cramming
part. Now, the problem. I make this visibility
gone for the user. But also, I'm not seeing them. Of course, I still
see them in code. This is the good of code view. And it's really
hard to work with. Because as I say,
I can't see them, and I can't understand
how they are look like. I showed you extra tip
in very beginner level. And if you forgot, I show you again
so you understand the thems I just to you
in previous sessions, they are base fundamental
and very important thing. Let me just show you an example. I just press inter in here, and I just wait a second to see, do you know what
should we write? Yes? Of course. Tools, tools, visibility. And what should we
give to these tools. Of course, we give this visible. What just happened,
what just happened. What we use these tools. We use these tools to see thing unchanged thing just for the programmer
just for myself. Not even in emulator
just for me. It's for nobody just for myself. So I can see this visible. But even if I run the app, and minimize this
and click game. I don't have it. Why?
Because tool is just for me. Do you remember Do you
remember where do we use it? Hide this, and of
course, stop it. These numbers just down. We use it to see
how many numbers can we fit inside this result, and we just make it
visible to see how b and how does our card
view just look like. But when we start the ap, APK on user device or even in our simulator, In our emulator, we see this gone, and this visibility is just for this design view at the moment. So exactly because of that, I add visibility for tools Android for
user tools, for me. I hope you understand it well. And you know we use all of those things in very
basic view, lower basic. Many other places. Exactly because of that, I mentioned those
things in there. Now, of course, in
beginner level, we understand many other
things and in the future, because these are
also important. We use these as well. So learn these carefully. So let me just copy
this to select this. Control see on your keyboard. And inter in here control V, and of course, not
text input edit text, but text input layout. Inter and control V. I have
all of my objects back, but just for now and for myself. I run this app one more time. You don't have to run
this a as much as I do. I run this app because
I care about you and like to show you
what just happened. So I have these objects to
see what just happened, and I don't have
these objects in. Sorry in this page. Let's continue on next video. So we write some line
of. Kathleen Cats
55. Day 8: Writing Primary Game Codes Part1: Writing primary game
codes part one. This is our app that
we want to create. Let's continue our app. We go to game activity
C T, to write codes. First thing is user click
on this start button, and then we check first number and second
number is then empty. Let me just close this
one and this one. So we have our two
important things and change the orientation bar. Grab one, the other side
or the side sorry or here. Just like this, you
can arrange them. Here my view and here my code is I just press tab
another tap to be here. And I write in it in it
listeners and open and allows. I don't have this function. I just click on it. I and inter, create function
or that light valve, do the same to do, I delete this to do. This is my function.
But I just want to use binding that we already
told in beginner level. So I just click here
and press inter. I write binding. What kind of is this? Activity gain binding? Question mark is equal. Null. So I just write
w binding. What is it? Activity gain binding? Why activity gain binding, activity game activity game because it's my
view, not my cutlin. What should I do now? I see this has an error. What does it say? I say, I need the lass, I should import that class. What Klass? I should import this activity game
binding lass. Okay. Do I have the in my main
activity? I'm not sure. Let me check. I just
go to main activity. Minimize this, go up up up. This import activity
main binding. Activity main binding. Just like that, I have
activity game binding. Just minimize this import
and go here in here inter, I just want to separate this. Create, and before
set content inter, I have this binding because
I want to give this value is equal equals to what equals
to activity, game binding. I just write the A dot inflate and give it layout inflator. If I say this line
of code very simply, I think I could say we
just to render to pause our layout So we inflate it
because we want to parse it, we want to fell it
into our binding. We want to feel this view
into our binding variable, and because of that, we feel it inflate command. We want to create elements, create one element view element from our file that this method, this inflate method, do that. And we should give
it some input. And we give this
layout inflator. I hope I say this simple enough. And with this code, and of course,
activity gain binding. It's a part of
activity gain binding. We give this binding our view, this activity game view. Now, what should we do
since we fill this binding, We now can use it. Because this binding now
filled with our activity game, we can use this binding
instead of our activity game. This resource layout
activity game. This is exactly address
of this activity game. You see, resource layout, resource layout activity game, exactly resource
layout activity game. So minimize this.
Now, we want to set our content view and
instead of addressing like resource layout activity game because we feel this binding with the whole activity
game that XML, we can use this binding
instead of not just this, since it's filled
with the whole view, we can use binding, and of course, our
question mark, and of course route. Now, it's okay. Now, our binding route that is our layout file is
in set content view, and our content that is this activity game connected
to our game activity. I really hope I put
this together simply. And what is this route? This is our root view. The top layer of
the whole thing, et cetera, the whole of this. Let me just say it in this way. Root element is the top element, top of all the other thing. For example, even when
we do web designing, if we want to say
in web designing, what is root element? We say the top
element, for example, in a HTML page, HTML tag is the toes element. So that is root. And in here in our
binding, what is root? What is the most top thing? Of course, the whole page. The place that contains all
of this XML is our root. I hope I say this one
simply enough as well. I also should mention, we defined it globally. We talk about globally in previous videos
because we want to access to this variable
inside other places, not just here. Okay. Let's back to work to see, we understand all of
this and we write this. Now, what should we do? We write binding dot sorry
question question mark. Dot app. Don't forget about
that question mark. So since the apply, we doesn't repeat that
question mark. Let's continue. Now I write pn, PN, Pn start dot set set
and click listener. If you suddenly write
two parentheses, remove them and shift the
button after P and in there. I have my C, set and click listener. Just remember if you forget
about this and of course, binding, you don't
have the TNS start. You should write this
a binding that alo. Don't remember that. Now, I just mention it. Let me explain it more. Comment this again. I don't have PTN start. Let me just control a space. I don't have it. What
should we do in this case? We should write
binding question mark. Do PTNS start. Why? Because we should repeat
that binding many times. And because we want
to don't write this, we simply write this apply. And of course, even said, put a question mark. You see, instead of
this question mark, and this binding, I simply
write this apply anyway. I just have a fast with you. This null means nothing. We make this binding null
label with this question mark. We put this question
mark in here. If this binding B null. This apply part won't run, and we don't have any error. So we click on it. Long story short,
we click on it. What should happen? We
should go activity game. First number, second number. Are they empty or not? So let's write code, but we can do something better. Let me show you. Open this project, came to this main activity,
came down down. In this main activity, you have this private
function from here to here is not empty input. Control C, then what
ellos this down here, when it listeners
finish, inner, now, control V. I just copy paste it so you can see
how easy can it be. But you can write it
to better learn it. Let me just show you the code. This is the code you must write. But it's okay to copy paste when you know what
does the code do? But from time to time, it's better to write
some code and left. Anyway, what does it do? It says if my DT first value, that text means the text that is inside the
DT first value is t, do this DT first value. Error should be this. What is it? Let me show you. Please inter first number. This is our string. You see get text or do string in verse
input please error. And the same. If not, for the second value that
text, do the same thing. Else return to. If any of this happens, we set this error message. We won't go any further. This never happens
and we have false. Instead of writing, I
explain all of this to you. I think my video can be
a little more compact. Anyway, Let's go up there. TNS starts, set on
click listener. What? Of course, if what
is not empty inputs. I just write I it
just the whole thing. Now, if this isn't true, and this isn't true
now, we say true. This has something and
this has something now, we say tru now because
they are not empty, we want to run the rest. What now? We want
a random number. Of course, a random number between let me close this
and minimize this again between this and this random number between this first
and the second number. So let me write
random dot. Next in. It's a default and
50, for example. What does it do? It's a function
from the android itself. It gives me a
random number 0-50. I can't put any number
for example five. It gives me a random number 0-5. Or 70 gives me a
random number 0-70. I don't want 0-70. I want a number
between this and this. Now I want to say
for a start, EDT, second value dot
x because I want the text dot two string
because I want a string, and of course, I can't give random next string dot to now, I can have a random number between zero and second number. I think it's not ok. Let me just press in
there and in here. I say get random number to pass this theme
to a function. So all of our words
be in the same place. Open and close. It
should takes two number. Of course, this is
my first number. Control C, and control V and inter and shift and the button next to the
M s without shift. Button next to the M and
another control V. S, not the second value. I just copy that. E, first value. And of course, V A is equal to the results
of this function. Let's just comment this as well. So click in here. We don't have it. This
time, light bulb created. So So I have my
what should I say? First is ino course and my second is ino
course and my result. Let me just say
sorry with pig in. So we're here and random dot. Next in. I think this video
might became long. Let me just divide
it into two videos. We continue into the next video.
56. Day 8: Writing Primary Game Codes Part2: Writing primary game codes
part two. Where were we? If I want to have a number
between first and second. First, I should understand which one is lower and
which one is bigger. Why? Because we're not
saying definitely, the first one is smaller. Maybe we put bigger
in the first one. Let's just do this
press home inter go up, R, what mean? It's minimum variable
equals our first. Of course, R max is equal to. Second, by default, I guess
maybe first one is lower. Second one is bigger. La now Now let me just
add an if if if what? First is bigger. Then second. You see what just happened, and open and close back inter. We say mean is equal to second, because of the
second is lower now. And max is equal to. First, you see how easy is this? Now, let's just have in turndom, max that we already decide
which one is max minus mean. Peels one. Do you see what just happened? So we say what is Max, for example, we say 50-100? What is Max 100? What does mean 5,100
-100 -50 equals to 50. Okay. Now, we have
50 tell us one. Now we have 51 0-51 is our range. And we add mean to this i because we don't
want the range 251. We want from our mean
So if we have zero, we add that 520. If we put 50 inside the first, we add that 50 to the
For example, from zero, if we have zero, we have 50, and if we have 50, we have 50 plus 5,100. We have this range now, and of co, we shouldn't forget. We should return our number. I have the error for a few
seconds and then it's gone. It's Android Studio bar. It takes time sometimes
to the error that says, you don't have
return will be gone. Now it's gone. We just want to see what does this return to us. How can we do that? Let me say, we have this
get random number in here. And at the end, for example
in here, I press inter. I say L, what is like, you just going to see. Look do I. Let's give it a name. For example, get random number. So I have this error. I will go and check
the light pole, and I believe that
things can help me. But since, for example, I'm just a Android programmer one month or maybe
one year experience. I don't know much about
these kind of things. Exactly because of
that, I tried to Reach as many as
errors as possible. So you can see what different
things might happen to you. Like any other students
that I have in person, I saw they have many errors. Anyway, open this. Okay. Import class. Log, create class, log, create om, blog. Wow. What should I do? Which one? I don't know what just happened. Okay. Let me just
click somewhere else. I still have this error. If I see here, I have also error. If I go on it on resolve reference like.
What should I do? I don't know. I just write like
with a small L, and I change it to big L. Let me just see if I write L. What just happened
and press I dot, and then, for example. Now, I still have error in here. What should I do? You see if
you put your mouse on it, you see import class. I shift in there. And you have more
actions with Alt inter but Al shift inter
just click on it. Okay. Let me just shift inter. Does anything happen?
I'm not sure. Let me just again click on
this or when it's open, A shift inter. Okay. Let me just go up. It imports Android UT Log. So I have this now. Okay, I just remove this and I'm going to check
what just happened. I still have this problem. Why? Because none of the following function can be
called with argument supp. Why? Because I just give
it one parameter. But I should give it at least two string
string. The first one. You see? Now, I came back, the button next to the M, separate this and say, we have a just up there, we filled a dot. You see this structure, tag string, and message
string. This is message. This is tag and we give this
message the value of A. Now, the first one
is what we field. Okay, let me run the app
to see what just happened. But what is it? Okay, I just click on
this game and zoom, zoom. A little down. Now, the first
number, for example, the 50 that I said and
second number 100, and in here, I have this cat. Last time, I think we filled
this fit level error. Do you remember Because
we want to see error, we remove this level error, and we copy this random number, we paste get random number. I repeat that. I started my app, I came to my page, first value, first
number, second number. Now, I have this
get random number. That as you can see is for lock. I fill this tag with get
random number with the value. What value, the value of A, A is the random number
that we just return from this function and
put it inside the A. Then we have this A. We can put this A
inside our lot. So I convert this A to
one to one extreme. Then because we want to find it, we want the possibility
that find that value, we give it a tag. This is names, exactly name. You remember that? With name. Imagine you give
your value a name. With that name,
you can't find it. So get random number. Okay, I just copy
that. Put it here. With this name. I say, Just show me the things. Package Mine. What is Package Mine? My package, not
the full emulator. Just show me the things
inside my package. What is my package? My own app. Not the other things
inside that android. Okay. Now, we have understanding
of all of these. And of course, on the
left side, log cat. Which one Lg cat? No wheres cat? We have some other
things inside here. For example, you see
this button, Kar cat, Klich or right kick,
Kleer Kar cat. Okay. Now, I have
this start button. When I press it PTN start, set on click liner. Runs, and then if is
not empty inputs, none of them are empty, then this value A. Filled with random number, then I put blog, get random number and
a dot two string. I believe if I press a start, there's a number in here
50-100. Let's do that. Start. I have 82. C do side 7624 learn
that my calculator. Why? Because this
is package mine. What is this get random
number? It's the name. I give this value. When you say it's a tag, so later on, you can find
that value with this tag. And of course,
here mont Day even our second minute seconds and
smaller value then second, you have and your tack, the exact time you have and your name of that
log, and of course, your package, where is that your application or other
application and the value. I have this value of 82. Okay, let's press this again
to see what just happened. It should give me another
random number 50-100, okay? Start, 70 start 73, again, 69, again, 96, again, 82. Do you see what just happened? I create random numbers 50-100. So let me do something else. I say, for example, here is 100, but here is 50 to see if
that if, do you remember, that if this if works, and it detects our first number is big and second
number is a small. I just want to see two There's a lot of numbers
in here. What should I do? You see this button, Kleer cat. All right lick, and
where is Kleer cat? Just like that Kiara
for this button. This is as you can see
the L cat button anyway. Start 76, start 78, start 83. Now, what just happened? This just five. As you can see, all
of the numbers are between the range that we want. Okay. Let me just clear
it again and say, let me make it a little tighter, because I want to see, I just want to see if this
plus one really is necessary, I'm not good at Matt
because I'm not. But I want to see is
it good 99 and 100. If we forgot to
put this plus one, We don't get the right number. But now I should see am
I get my number between these two ranges between
99 is 99 also and 100-99. So 100 or 99. So let's start start. 100. Okay. Start 99. So I have 99-100 and the boat
numbers are also included. You understand what
just happened? Let me try start start
start start 199, 100, 100 100, one, 100, 199, just like that. I have between
these two numbers. So my code works just fine, and I have to write
these tell us one. And my range is two,
as you can see. You see, 100 -99 equals one, but I don't want 0-1. I want 0-2. It can
be one or zero, but not the two. Let me just do the mat for you. Comment 100 -99 equals one, and that one hells. Another one equals two. So you give give me a number 0-2 that can be zero or one, but not the two. And since I have zero or one, I add mean to them. Let me just a double
of this again. So if it's zero plus
99 is equal to 99, and if it's one plus
99, it equals 100. And how about two I say 0-2, but not the two. I hope you understand it. If you even take your
mouse on next in, you see gets the next random non negative in from the
random number generator, less than the
specific util bound. We put util inside as in, and we generate an intrandom
value uniformly distributed between zero and specific util
bound the maximum number, for example, the
number that we just put is not in that range. Of course, it says, that number should be positive.
And you can see. The next line says, it gives you error
if you put zero. And of course, we
put one to don't have error y because if
mean and max are equal, for example, 100, 100, 100 minus, 100 is is zero. So we give zero. We might have error. So we plus one. Why? Because we don't get error
even if they are equal. Anyway, let me just
try a few more times, or I just remove or
I just put it here. No, your code is messy. I remove it. Another,
another, another. Let me increase my range. For example, 500100 and start. 443 is 500-100. Another 381, 297. I hope you understand
this part very well. And I hope you understand, we should check our
code like this, 99 and 100 and put this to see if my code
really works just fine. Maybe if I put this and I
didn't write the correct code, I see, I don't have
100 inside that. For example, I don't have my
second number inside that. I check my code with the
slug as you can see. So it's be correct. And of course, don't forget
to select your emulator. If you put your phone
on and the studio, you should select your phone. So you can see the
log of that device. I think I mentioned it's just
for me, for the programmer. It's something for that
tool you see inside that activity for our view. It's something like that. Log is for me, not for the users. I think it's enough
for this video, we continue in next video and
just to stop and minimize. I hope you understand all
of this very very well.
57. Day 8: Number Data Types: Number data types. Okay. This is our
app. Let's continue. Last vision D complete this. I want to just point
a few things first. Let me just show you this game activity You
see this visibility for our text input layout,
Android visibility gun. We have this visibility
for other objects as well. For example, we do
this for our button. We also give this visibility
to our material card view, And I just want to mention
other objects like this text view has that
visibility property as well. Even this view, if I just
paste my visibility in here, this view will be high as well. Do you remember this view
for make a line in our app? Before I run the app again, let me just show you You
might have this error. What does it say? It say? This line might
never execute it? You write this if and
close of this end of this if and this part
might never happen. And it gives me error. So I just thinking, I should write else and if
not, do something else. But why does this
thing give me error? It shouldn't stop my act. Error is for what
stops your act. It's a big problem. But it doesn't a big problem. Okay, It doesn't execute
for what? I don't care. If not, I don't want to give you any errors because this
is not empty values, I give you the error. Because of that,
I don't have rs, but as you can see, It gives me error and the error
doesn't make sense to me. Let me just run the app to
see if it's run or not. Because when we have error, the app shouldn't be run. It stops from running
because you have problem. But as you can see,
at the same time, I have my error and
my app press game. My app runs. So what just happened? Let me just even write 99 and
100 and where is my lg cat? Clear this lg cat and Zoom. Another Zoom. Okay, I'm here. 99, 100. Show me. 100, 100, 100, 1019999, 99, 100. So I have a random
number 999-100, and also both of those numbers included and my random
number is integer. So I can't have
99.5, for example. We understand this, but
how about this error? Why do I have the error? I talk this much to tell
you this once in a while. Let me think, for example, one or two times in each month, I have these kind of errors
when I write a program? These kind of errors
Sometimes the bug. Yes, Yes, Let me say like this. Sometimes these errors are bugs. The Android studio buck. Because, for example, this
error should be on warning. Even not important warning. It should be weak warning. You see, I have
one weak warning. It should be on weak warning
even, but not error. So let me just since we're
here, check one more thing. What if I say, give me 100-100. In my code, just the
first one and second one. Take min and max and the if, isn't true, and we go to random. So I should gives me
a um random number 100-100 and it
should include the 100 and it should Just be the 100 because it is 100-100
and it's integer. So I don't have any
between numbers. I just have 100 because
both numbers are included. So let me just check exactly
that. Let me show you. This plus one after
me do the job. If not, the 100 isn't
included anyway. Press start 100 or just clear, its clear 100, 100, 100. I press many, many, many times. I just have my 100
because it's 100-100. And I just have one number
between between them. Anyway. One more thing since we're here, don't just memorize
it. Think about it. What just happens? 100 -100 is equals to zero plus one is equal. Let me just calculate
it for you. 100 -100 max minus mean equals
zero los one equals one. Now, I give this random
maximum number of one. Give me a number 0-1, but don't have the one. So it gives me zero, and I los is zero with the
number means 100, equals 100. I don't have any
other number than that zero and I
plus it with 100. Think about the codes. Not just memorize them. You can use this code everywhere and all the
time it's correct, but you should know
what are you doing? Not just write the codes. Exactly because of that, I try to give you
this much details. Anyway, as you can see, my error is gone. Why? Because just the second, I write something that this ID refresh and the error will
be gone, just like that. Let me just remove it. So if I write anything,
those errors, I just show you they're gone. And because of that,
exactly because of that, I told you sometime these kind of errors happen and
just Andrew the Studio. Of course, from time to time, Andrew the Studio
give nearer update and these kind of things
became lower and lower, but you should understand
these things sometime happens. So let's just start, we stop the app and minimize and minimize and continue So the
first thing I want to do, I want to comment this like because I check my
code and it's okay. So I comment this. Since it's on the source, you can remove
this comment part. Or as I suggest, you write it your own. Let me just go to
this activity game. I have this, I
forgot to show you. This view is hidden. Our line is hidden. This view is hidden because
write visibility gone. All the other objects that you can see has this
visibility as well, I just want to mention that. Stop again, minimize,
and I remove this line because we don't
want it to be invisible. What I want to do. This one input layout guess, not dit guest, input layout guess that we just
say visibility gone. We want to show this show
what input visibility? Yes. I just double helice
Control C and go ta ta tab, tab, and tab, and control I think it's better
that I write it in here. But anyway, I have this. How do we hide this? We say visibility. You see visibility go. Let me just go back and say, I want this input layout guess. A property of this, which property, I
want the visibility. You have all the property. All the properties are there, but I want visibility
because so many of them, I write two find it faster. So visibility. I write is equals to V.
Of course, with V dot. I have visible. I have gone. So I write gone, and it does exactly the
thing I did in here. Visibility gone. It makes the property
visibility equals gone. So with this command, I make the visibility property. Gone. What if I write only gone, can I give the visibility
the value of gone? No, I cannot. How about visibility
with a small Sorry, view with a small V. View dot. It's something
else. No, I cannot. So pig V, view dot gone for
make the visibility gone. But I want to make it visible. So which one You see this visible or let me just
write in visible. I have also invisible as well. We have three different
options for that visibility, and I have invisible as well. Anyway. Let me
just visible this. Let me just run the
app to see what happens because we want to know. You don't have to run the
app as many times as I do. Anyway, five and 55. If I press start, input layout guess
should be visible. Start. Oh, your guess, it's visible now.
Just like that. We make it visible. I want to make another thing. This go 110 PTN go. I want to make it
visible as well. We give this visibility gone, I want to make it
visible. I want to copy. I want one copy of this line. And I don't want to
copy it to other Ps. Sure. So what should
I do? Control. Let me remove this. Sorry,
I just press Control P D. I write it like this, so you can easily read it. So I write control. I press control D and
my line duplicated. Let me just do that again. Control D on my keyboard. Control D. Just the
line next to it. I have a copy of it. It's just like I pre
selected control C, and then came here and then pressed in there
and then control. Oh sorry. I even do that wrong. Control C, and then inter
and then control V. It's too many sets. You see, select control C, go to the end,
press in Control V. So what should I do instead, I just go on the
line that I want. Press control and then
D. I duplicate it. So you understand the triage. Let me remove this line and I'm not going to activity
game to copy the name of To. I just want to write
it in here, BT go. Since I say we should write, I just write it in here. But sorry, I don't want to
even copy this controls. And I told you a new anyway. So now we want to The
user guess the number, and then we store this number, this gas inside a variable
and then check it out. So we should define a variable. Instead of be in
here since I want this variable to use to
be used in other places, I want to declare
this variable gb. So I just remove it from here. Let me just go up up up
just after this binding, it's also a global variable. Let me just say variable
Not a random number. It's a good name
for my variable. What is this number type? We talk about types
later in this video. But for now, let me
just give this in. It's an int. Is it
good? I go back. No, y please, give it a number. Add initialize there. I should give it a number. I came and say,
Okay, You do this. The Android studio
give my variable, the number zero. It's okay now. I also can give it null
and give the number later. But I just say, give it zero. But since the zero can
be one of the guesses, maybe I should go to minus. For example, minus one
out of my guessing range. I think it's better. Let me
just go to main activity. I open this main activity. Do you remember we
have followed in here? For decimals, we have
followed and double. You see, we talk about it. Flowed and double. And we say after the digit
after the dot after the point, the decimal umber in fallowed
is about seven number in our test and for double is about 16 number after
the decimal point? So we talk about them, and we also introduce int. We say, you see. If you are less than 1 billion, you can give it int. If you are going
more than 1 billion, please don't give int. And also talk about
a string B and fot. Okay, I talk about
fot and do now. Let me just close
this and continue. So as I say, we have many
other types for integers. We use lots of times in
because it covers many things, but we have other types. Let me just show you. Where should I write? I think in here is good. A equal is the
type of byte then. B what happens if I
don't write that? For example, just want
to write short. I can't. I should add shift and the
button next to L. If not, if not, it gives me
error. I should write it. What if I write a
small S? What happens? I have error, so just
capital S. I cas sensitive. What's next? C? What is it? Of course, with big.
What's the fourth. Long. Sorry, long. I think I mentioned
in previous video, we're going to talk about long. Anyway, what's the difference? For example, if I
want to give not even 1 billion 100,100 million. It gives me error. Why? Because BI can't have
this much big number. This kind of number
is too big for by. Let me just remove 200. What about? Not even one. I usually use it. Then my number not
going more than 100. I just write. Byte is -128 to 127 when I value is lower than 100, I use byte. I don't like to go the
exact capacity of variable. How about short? Short is from -32,000 7682 Pella, 30,767. So let me just check it. If I give it one. Is it okay? It's okay. Ten. Is it okay? It's okay. Hundred 10,000 s. Well
not go beyond 2000. It's just 10,000. What if I say 100,000,
I have a row? Because I can't give more
than 32,767 in this. So it must be lower. You see, I say exact
number, it's okay. But one more, it's not okay. You can't give it even one
number more than that. So when my range is less
than 10,000, I use short. But many, many times I
use int because it has a big range and For many
different things, I use it. My incapacity is just like this. Of course, it takes
number to 2 billion, but I don't want to
give it 2 billion. I give it less than 1 billion. It has the capacity, but I don't want to
fill the capacity. You see the bite. It said, it's okay to say
bite because you want to use bite.
You see the short. It said it's okay to give short. But sorry, I should lower this. It's okay to give short. But you see in it's different. It says you can remove int
and just give it the number. Let me just show. You
can remove this int. If I click on it, it removes the int declaration. Because by default, as I say, the int is most common
type of variable, and the cutlin give
in itself when you put a number
inside the variable. Because since we're
teaching, I put in. So we understand
that int is default. How about long? Just write it down in here, so I just can copy them
and give them in here, put them in here and
paste it so long. Can you see the difference? Okay, thousand million billion. Oh, my God. Thousand of billion billion, million of billions. And 9 billion billion? I think you can't
count the number. It's a really big number. So when I use long
then my number, it's go more than 1 billion. Of course, you have the maximum
number in here as well, but it's very big and it can calculate and accept very
big range of numbers. Long story short, why there
are these different types? Because each of them
has different capacity. For example, let me give you explain example, for example. If I have a tank with
1,000 liters capacity. Is it okay to use it to a
sore only one glass of water? It can, but it's not reasonable. For example, if I use long
to assore the user age, it can do that, but it's not reasonable. It's most common to
use in sometimes if you store many
datas, many times, many repeatable
datas, it's better to use less consuming datas, like these or these
if it's possible. But if we use only one or
two or even ten numbers, we usually use in. If you can't put your
number inside in, for example, population, You can't put it inside
this or many other ts. You say, Okay, now it's time
to use a bigger number. For example, long. I have one more type if you
can't put it inside Long. Let me just show you that R, I give this a name. E, what is the type B integer. We give big integer to
this E. It is very big. Okay Let me just give
this big integer number, one, two, three, I can't y? Because it's different
than the others. I should say in this way. Big integer. Sorry, remove this
dot value of one, two, three, for example, four. Let me just continue this in
next video because I want to create a function and
not put them like this.
58. Day 8: Big Integer: Peak integer. This is our app. Let's continue. Where we. We want to put this inside a function or just write a four. Let me just write a four. I just press inter. I write four open and illos. I n 050, for example, and it adds the to let me know, it starts from zero, and it goes to 50. So I have my i from zero, then one, two, three, four, five, until 50. L et me continue to see
what just happened. We'll just make it 49, we run it 50 times and
we give this 50 as well. Run our code a few times. How many times as many
times as we decide. For example, I decide, I do this 50 times 0-1, two, three, four until 49. And if I want to see
I in which of them, I can use this I
inside the four. And each time this I
has the value of zero, next time one, next time, two, next time three. Anyway, let's continue. I say E, E variable is equals. So I want to put something
inside my e variable. Again, e. So until here, I
put E inside my E. Dot multiply, and I
can put B integer. Inside this, I write
integer, and again, sorry, I remove this dot
value of or no, just 50 it's okay 50. So I have 50. I multiply this 50 with 50
and store it again in E. And after my four is finished, let me say like I open. I should say a tag name. Let me just say E, I can't give this like I the E. Y? Be it should be a string. Let me just show you this I should take a string
value from you. See a string and a string. Tag is a string. Also, the message is a string. So I should give here a string
the tag and the message, of course, should be a string. So You have to say
dot twist string. If not, you have error. I put my E, my big
integer inside this log, and of course, big integer. I give the tag, big integer N. Let me just run this thing. Even I don't need the function
now. Let me just run. The cat, I clear this, let's go to gain. Get random number. Yes, we put this to see
only get random number. But we don't want this. We want big integer tag. Control C, go here. Control. Why? Because
I want big integer. If you don't do this, for
example, big integer one. You write something else. What just happened? You
can see your result. Imagine you use this
like many times, and if you write any of these
wrong, you can't have it. Or even if you, for example, write here, Big integer one and somewhere
else, Big integer two, if you just write, for example, Big integer 11, you can't see any of those. So you should be careful. The same thing, you want to see them in the
same category. You should be careful, give them the same cat, so you can see them
with each other. I hope I say it clearly. So what do we have
here, big integer. Let me just see the number. Okay. I'm not very
good English speaker. And if you are, I believe even you can't read this number. Let me just count how
many number do I have? Let me just say, if this much is about ten number ten digits. Sorry, ten digits. I think it's about even
more than 100 digits. And honestly, I can't say
any name for this number. So you can see how
big is big integer. First, I want to show
you something in my log, and then I go back to see
what do we have in code. Okay, stop, stop, minimize, minimize, and as you can
remember, control D. I have, for example, these two, and I can say heels
string hes, string, and inside here, num one space equaled a
space in here num two, and space of course
and the space. Let me just run this again. I just clear like that. Let me just go to this page. I have big integer
b integer because I give the t this name, big integer, so I can find
these two with big integer. You see the time is the same, Because we clear the older one. It's almost important, I
can't say rule. It's a trick. You see, I have this data, but I have more description
because I have a string, I can add another string to it, so I can put number
one is equal D, and number two is equal
this or even in the start. Then when I say pig
integer and I have five or ten different
pig integer or any other thing
inside my app. I log them all, but
I can't understand. For example, this
number, it's from there. I not remember this number, which one is this number? I add something at the
end or at the beginning. So I can understand, this is number two,
it's this one. This is number one. It's this one. I think after at let one or two
years of experience, you add some of these tips
and tries to your code. It's not really the thing
anywhere teach you. It's just experience. Let's just stop the ad. As we understand, we can
say the texts and pelos, what is in here, for example, game acti even line for it. Even this. Okay,
I'm in that code and line somewhat in that line, that activity, and there, I have this data and it's this. And then when I check my app, all the pig integer. Why do I say Pig integer? For example, data data test three data test from
database, any other place. It's just the name. And When I check it out, I can easily understand. Okay. So I have that data
with those problems. Okay. How can I find that data? Because, for example, I
add the log 200 plays, and I'm looking for
that error many hours. So, I can understand. Okay, this run data is
online 40 in this activity, and this is the round data. I hope I explain it simply and you understand
what just happened. Okay. Let's talk about this codes. I say V E is a big integer, so my variable named E is the big integer and I want
to give this E value. Let me just come
in the is and say, Okay, give it five. Is it, you can't give it five. It's not by short in or ling. You should write big
integer value of something, so you can give it the data. But the number, the number. So if I go in this
error and open it, the change type of e to t. Do you want to give it five? Give it to int. Y big integer. What if I say, k, big integer value of. For example, even that five. It's okay. You can give it. Then what happened? We add a four. What does a four do? A four, repeat your code
for definite times. So what just happened? I say, I need a four and I
call my variable for that f. I can't say anything. You see? Let me just say ABC, for example, and I say capital A num ABC caps and Never use it. Why? Because I don't need to
use this value inside four. I just have this and each
time this increases. For example, first time, if you check what
is it, it's zero. Next time, it's one, next time, it's two. Let me just show
you that as well. I comment these lines. Copy this in control
V and big integer. And I want no Myb C to string. Let me just see what do I have? Run the a again. Do I have any cat? Yes, I have. Clear it. I clear it, and I say, I want I. I don't have any. Let me go there. And until 49. From here, let's go up up and
equals to num two. You see equals to num two. This one. I just want this one. Because Autopil manager also has by mistake, autopil manager. You can also see that as well. I should put a longer
name, but it's okay. Let me just see what is
the data that has equ two. I first time that my four runs, I have zero inside
this numb ABC. Next time is one, two, three, four, 56, and it's until here 49, it less or equals to 49. It runs until it's equals
to 49 and then it's done. If you count it zero, 249. Since we have the zero as well, we have 50 times of run. I hope you understand
this part as well and stop this anyway. So I commend this as well
and change it back to No, I don't need to change it back. Anyway. Let's continue. I have zero, one, two, until 49. So we understand
this part as well. And as we already say, I want to give this
big integer the data, but I can't put it
with equal sign. So I should say big integer
dot value of this number. So I have 50 inside my
E. In the first run, I mean the zero ty. I have this like this comment. 50 This part e equals 50, dot multiply, just like
this star for integer. So we have this 50, we multiply it to a number. Just as we can see dot
value, we multiply it. Just like you put that star. To a number, to what
number? We say. We just can't say, Let me just control x and
instead that say 50. We just can't say that. The integer you can't put
it inside the big integer. So you should say it's wrong. You can't put the
number like that. You should say big
integer dot value of, so you understand it
as a big integer. 50. So the first time, I have 50 multiply 50 equals, I'm not good at mat, but I think 25 and 20. You can put it in calculator. I think I put the right number. It's the first run. It's the step zero. What about the step one? In step one, I say, you see this 2,500, I put a 2,500, I just calculate it
and put it inside E. I have in the second time, I have this E with
the number of 2,500. So I multiply it again
with this 5050 equals two, I put it on calculator
and C. I have 125,000, and we do this until step 49. Exactly because of that, we saw that very, very big number and we see
the capacity of big integer. Big integer is different
with these simpler types, and you use it
very, very rarely. But if you need a big number, you should understand there is a very big number
inside this language, and you can use them Just
in time, you need them. Even this line, we use
it when we need it. Also, before I forget, we have different
ways to use for. This is only one way
we put two dots. Because in this lesson, we don't want to talk
about for a lot. Just you should know there
is a four and I stop talking about different ways
and talk more about four. In the future, we get to
know about for a lot. We use it in many
different ways. Just be patient.
Just to be sure, this multiply is just
for this big integer. For example, if I press
inter and say this D, this is long dot. I just go copy this to be sure, all the word exactly the same. I don't have it. You
see? I don't have that. Why? Because long
doesn't have it. How about in? I have minus. How I have d. But how about
multiply? I don't have it. This is just four big integer. This type. Long in
doesn't have this. Doesn't need this y because
I just can't say d is equals d multiply d. And
it says change to y. Why? Because you say y. Okay D error. No error. Why? Because you
don't need multiplier. You can't just use this star. This big integer, as I say, is for specific works, very big numbers,
and heavy data. And because of that, it's not with
regular multiplier. Is this special command
for multiply the number. And even the input
that you want to multiply with that
should be big integer. I just comment this with
slash star and where we finished star slash from here to here
we comment it all. I leave it here. If you need, you
can uncomment it. You just have to
remove this part, and of course, the end. I just comment it again. I think we talk about
this kind of comment, multi line comment, not
just comment one line. If not, we just saw this again in here and we
get familiar with this. I continue in next video.
59. Day 9: Checking the user's guess Part1: Checking the user's
guess part one. We have this game
and in this part, we want check the
user's guesses, and of course, show the result. But we also cover
some other things. For example, null pointer
exceptions, or even the like. Let's continue. Okay,
well come back. Before I start, let me just talk about four
a little bit more. We just write in here R four, and in this four, we should say we
have a variable. For example, i, and we say
you can say any other name. This variable should be in a collection or in
another word arrays. Since we didn't talk
about arrays yet, I think we should
talk about them and have more example
of this in the future. But as you remember, we say or in a range of number. We don't use in arrays yet, but instead of arrays, we say, for example, f in between zero and we won't say
until another number, we say dot, dot until
what until ten. We have four 0-10. If I just say like, I just copy this. I don't write it again. You see after four, we have opening And when we're
finished, we have closing. But in here, since
it's just one line, we don't have to write that. Anyway, we don't have E
because this is comment. I just say I. Why? Because I want to
see what is my i. And I say I value, and I don't change it num two. Why not? It's something for
no reason that I just write. Let me just run the app
to see what just hap. It said in a sal
successfully in 2 seconds, but I'm waiting for
about 20 seconds. For the first draw when you
open your Android studio, it took a few a
little more time. For example, 20 seconds, it takes 20 seconds to run. I just want to say L cat, and I want to clear
this and my eye value. So I copy this control C
and delete this control V, my e value, and of oom out, and we want the game. Again, like that, I just want
to loom and click the game. My eye value, you
see my eye value. I have this my eye value. What is it? It's start from zero, and the zero itself. This one, and it goes until
ten and number ten itself, zero to ten, zero to ten. If I count nine, ten, 11, we run 11 times
because one to ten, and we have this zero
itself 11 times. Can I write it in a different way instead
of these two dots. I can just write until. You see that dot, I have it, F zero, two, ten, zero itself, ten itself, and I just select these
two dots and say on. Is there a difference? Can you see any
difference in here? Look at this, this. I think it doesn't have equal
part. What does it say? If I stop the app and
run the app again, And I just see the cat. Of course, clear this cat with this button or right click. I want to go to game. It said from zero, one, two, three, four,
and until line. Why? Because I don't have
the equal part in here. If I write until instead
of those two dots, I don't have ten itself in here. I hope you understand
this as well, Let me just write
another thing. Stop the. Of course, and
minimize this R, what? Max I, for example,
Mx equals ten. Then I write in here, Max. Is it okay? Let me run the app
and check Run. Of course, like. Let me
this time leer this pot, Kleer, and click the game. So I have 0-9. If I change it, let me just change it to eight, and of course, clear. If I go back and press game, I have it until nine. Why? Because I change the app, what my APK is already
installed in emulator. Don't forget. And pay attention. My app is already on the run. I change this number. And I didn't see that. So I go up here to
see I have drawn. I pressed this button as well. I'm waiting and it
runs again very fast. Less than a second. And of
course, click Logcat again. Clear this logcat, click again. And now I have it 0-7, not the eight
because I re until. I hope you understand
this part as well, and I want the eight itself, Let me change it, dot, dot. I should have the eight. Let me clear this and
back, click the game. Where is the eight?
I don't have it. I. Let me repeat this again. You should run your app. This is your old app. You change your code, and it's not effect
in install app. Let me put it this way. Imagine you have your
output, you install it. On your phone, you
disconnect your phone. And whatever you
want to do in here, it doesn't affect
your phone anymore. This app in installed and run, you change your code. So you should press Run app, then your new codes, and whatever you do effects. If you have an error, you fix these things, you should rerun your app. If you do any other thing, you want to see the effects, you should rerun your app. Even on your phone, you should re in
solid on your phone. Again, cat leer game. F028 and eight itself. Now this is something so I
understand one thing what? I can put this number inside
a variable and control it. How about this number? For example, is it okay if I
say R mean is equals zero, We have error, y because
I put this space, and of course, I
want big I in here. I use this mean instead
of this zero, mean. Is it okay or do I have arrow? Let me run. Of course, we go to
check users guest, but, since we talk about four, I just want to check
all of these to see if these things
are okay or not. Ga, it's 0-8, and if I change it to
anything other than zero. For example, I say five. Again, if I go back
and came again, since it's a salt app, it's not updated yet. I didn't see anything. I don't do anything. So run the app again. Like C. Clear and game. I have five, six, seven, eight, um five and five sel, 28. So we understand that. Please write all of these
things with me step by step. All the courses, you shod write these things
with me step by step. These things important, and you understand these
things anyway. F five, and five itself. 678, and the eight itself. It's the different between
these two dots and t. Okay, I think we have enough
examples in here, but I still have this question. And as I say, let
me minimize this. You see, because it's one line, I don't have shift the
button after p and closing, shift the button after
two button after p. Closing. I don't need this. But most of the time
I write it. Why? Because I might add codes, and if I don't write this, for example, let me show
you that example as well. D, D is. And What is control D? Do you remember?
What does it do? Control D. I duplicate this. First, I have this error. Why? Because it
doesn't recognize, because you're outside of four. You don't open on allows, only the first line runs. But since I want to show you, I can simply remove
this and say, num one, one, two. To show you what's
the difference? Imagine you forgot to open Akos. You say, it's one line. Any comment any other
thing you want, you write. Okay. What you forgot.
You forgot what? You forgot to open anks. Another time, you
add one more line. What happens now? Let me rerun this
Logcat leer gay. I have this line with 45678. But this line four
doesn't run this. Please run these codes with
me and see it yourself. These are important. 5678, but this only ones. If I consider that this
must run with this four, as well, these two
lines are together. I don't receive an error. You see the app doesn't
say you have a role, but my app doesn't work as I expect because this
only runs once. So if I say it starts in
here and ends in here, shift peels, the button next to PN, the
button after that. So I have this ands. Let me rerun and look
at and clear and game. I have five, num two. I have num 112, and again, six, and again, seven, it runs
runs every time with me. With this line as I expect. Because of that,
most of the time, I put these on my four, even if on my if
I can eskep that, but most of the time, I do not. One more thing. I have a really, really
important question. Why do I use four? I use 42 do a line, a bunch, I can't say a line, a bunch of code because
it might a bunch of code or specific
number of time. And I can have those
number of times with a certain index that is lower
index, and upper index. If I say five to eight, I have it five, six, seven, eight, four times. I run this code four times
both of these lines. But what if I say
I don't want it. I can run this code for myself. You see, control V We
run this code one time. Y four. I have this
question, y four. Let me just just do control D. You say you want to
run this code twice. Control, I have
two of this code. We run this two times. Even if you want that number, I can give zero and one, I have zero and one myself. Y four. Okay, let me just
continue of this action and say control three
more times and say, this is two, this is three. This is four Is it good? Let me just comment this
and say this is 0-4 itself. If you see, I have
one, two, three, 45 lines, and I have one, two, three, four, five lines. It's the same, I
have five lines. I have five lines. These are equals. But one more thing, first of all, I can't
control the numbers in here. I should write e and check, and it's really complicated. It's not recommended at all, but we want to try. If we write like this
or even more, 20 times. What if we want more? Should I change
everything and have any other kind of s
and what should I do? I write, for example, 500 lines, and I have 500 es
to check what is I and if I run this line
and check it on ef. What if I have error because I write
something wrong in one line. It can't do like that. Especially you have
five times in here. Imagine 40 times. What do you want to
do? Let me go bigger. 100 times. What do
you want to do? Do you want to write it
100 times? No, you can't. How about 1,000 times?
Of course you can. Because of that, when I
want to repeat my code, repeat my commands certain times I use four. Four is very useful command
and we use it in many places. Instead of this or
write it 1,000 times, I just write very short code. It is clear, I can
understand it. I can't debug it. It is really simple. It's very good and efficient because I have
less errors as well. It's really fast because I
write it fast. Saves time. By the way. I just in here, star slash and in
here, slash star. Why? Because I put this
for you to see as well. What is our previous videos? We talk about these
numbers, where are they? Byte for about 100
maximum from -128 to 127. Short, a little bigger in, very big long, even
bigger than in, and even we talk
about big integer. Why do we talk
about all of this? Because I want to see which of these variables is good for me. For example, because we
want to guess a number, I think bite is very little. Short is good. Most of the time, I use in
and Android default is in. But let me use short. I just copy this
part, Control C, and take our short variable
to get random Control V, I add slash, of course. We want to give this
number, for example, minus one, and we
Put this control x. Let me just take
it and put it in on top our code to its
a global. In here. We want it a random number, good name, and instead of p
short equals to minus one. I just clean. This I have random number
short equals minus one. Since we want to change
the value inside our code, I should say, not that. I have variable random number
short equals minus one, and I say comment This
is the range of short, so you know, this is the
range of short, anyway. Let me just select this
by double click on it. You see double click. If you click three times
very fast like this, one, two, three, you
select entire line. But if you want to
click one time, you change the place you
are here, here, here. But if you click two times, you have double click. You select this part. Control C. S If I teach
you so many details, it is important to me, so you understand
every of these things. Anyway, let's go
down random number. Control V equals. Oh no, I have error.
What just happened? What's our error? Isn't
this random number? Short. Yes, it is. Let me just check. Short. But what is our get
random number output? Let me just check that as well. Control and click on it. Let me just go back in here. Control on this
press control and click to see the destination. Let me say so. To see the sores, get
random number. What are we Bring to our variable. We return int, and
in that place, it says, you can't convert
in inside that short. In some places, I should
change this int into short. If I change in
here in short it's okay and I can't
do something else. I can't change it
to short in here. I say, do something with
that method for me. I want to change it, I even don't write anything. You see, too short. I also have to a
string that we use it many times to in
anyway, too short. We have our int, we change it too short, and then we put it
in random number. As I told you, I always
most of the time, sorry, most of the
time I use in. I just want you see how
can you use the short. And if you go up and change
this short to in and go back. You see. Now it says, why do you have short
inside that in? You should convert it
again. Let me just see. Can we just say that in? It's really, really bad. We can do this, but
I don't want it. Anyway, instead of have this in and change it to short
and then change it to in. It's not a smart at
all. It's really bad. I just remove this part
and it says, it's short. I say, and remove or
just comment this part. I have this int inside my int. Because we change this
variable into in. Let me just check it again. You see, my variable is in. Since I just want to see, where did I say random
number when we declare it, and what does it type? Maybe other minor thing, for example, our default value. I want to check this variable. I press control, move
my mouse on this. You see you can see it in. But no, I just want to see
the line that we declare it. I press control and click
on it to see, it's here. Let me just do that again. This is my random number. Press control, click on it. Oh, this is my random number. In here, I give
this value to it. I can change it to
minus two, for example. I can find it very fast
by just click on it. Simply like this. But how about other variables? Like for example, this binding, I want to see where we
declare this binding. Maybe to double check, change it or any other thing. I press control to see
is it working as well? I click on it. After press control on your
keyboard, I click on it. This is my binding. Let me do this again. I'm here. I see, I have this binding. Where do we declare
this binding? Press control, click
on this binding, Oh my binding is in this line. So we continue in next video so our video
won't be so long. Thank you for your attention, and I hope you learn a lot of these important tips and tricks.
60. Day 9: Checking the user's guess Part2: Teching the user's
guess part two. This is our project,
and we continue. Now we have our random number. We store it in this
variable just in here, and we want when user inter the gas and press
this go button, PTN go. We want to see if it's slower
bigger or the exact number. We want compare that guess
with this random number. We have our set on
chylic listener on PTN art that fills
our random number. But we don't want
PTNS start now, we want To see when does
the user click on PTN goo. Let's write. It starts
in here and it goes. You see the line until here. I just click. Press on inter. I write Pt N. G.
Inside this PT and go, I want to set on click listener. I press that and say
set on click listener, I have on Klick listener. You see you have two of them and you can
see the difference. If I click on the second one, what is the difference
with the first one? Let me just click
on the first one. I have the parentheses
and it gets input. What is the input? Or we just
shouldn't talk about it. Anyway, if you click on it, by mistake, you have this
and you have open and lows. Shift next to the
P and of course, the lows if it didn't add it, but I should control
the space again, the, the second one, that have that range for me. Like this and no parenthesis. Then when it puts my
cursor selector on there, I just press in there. The closing part goes down
there and I'm in here. Android Studio arrange
it for me. Anyway. Let's take this
your guess value. But I should check to see
if it's empty or not. Let's write and then I can just press in T.
No write open and kilos. I write open and lows for me. I write Tex ts. Text utils is for
android itself. It gives me the possibility
This is much possibility. Which one I want to use, I want to use the is empty. Why? Because I want to check if
my text is empty or not, and of course, it
returns bulion for me. So I can use it in true
or f. Anyway, is empty. Let's write e t, et gus, this one, dot text of
course is empty or not. I press and shift the button next to
the P, and of course, the button next to it for lose, I go back one character
and press in there. If it's empty, what
should I do? It's empty. Et gus, dot, I should
show an error. Of course, error is equals to shift the
button next to the inter. I press one and it adds
another one for closing. I can write my text. Shift and P for Big P.
Please, in your Yes. I think it's a simple
and reasonable text, but I should put all of my Text inside a string. There is a string string, and I have two languages. I should put this string
inside my strings. Of course, in Arabic
version as well. I just click on this text that I write and I press old inter. You see this extract string
resource. I click on it. Resource name is please
enter your guess and value, and of course, Arabic. Of course, I press
home and write STR, shift that writes
for me an underline. You can write any name you want. I always write STR before my string resources.
But it's up to you. And if it's too long, we can make it shorter. For example, if it doesn't fit, I remove this your part. So it becomes SDR,
please interges. I remove those parts that makes my string
a little shorter, but still my name
should make sense. So I I read this name, I should understand what
does these things do. And what does it for? I just click on, I have this r dot string
SCR please interior guess. And read the studio,
do this for me. Of course, if I
go to the string, SCR please interior guess. I have this with value, and in Arabic as well, we didn't translate the other. But you can see it. You can translate it anytime you want and I just
close it, close it. Even if you don't want to
open it from this project, you can't press control
to go to the source. I just click on it. First, I press control
and then click on it. It says, it came from
two different dos. Why? Because it is
English and Arabic. So I say, which one do I want? Show me the English one. This is the English one. But
if I say control, click. Now, show me the Arabic one. It goes to exactly that
line and I can see inside the Arabic one exactly that line that takes me there
and I see the value. Anyway, close this again. Besides this, even if I
click on different things, for example, EDT guess, you see this DT guess. Where does this DT
guess came from? Press control and click on this. I want to see the
resource reference. Click EDT guess came from here. This is my EDT guess. I understand now. I think I didn't mention, with this get a string, you take your string,
get a string, and for taking it, you should give it
the resource address. Go to resources, then
go to a string folder, and of course, a string foil
and take this string folder. Inside that string folder, depends on your language. Now, take this variable
that we give the name. Resources, a string folder
inside that string. Take this SCR for me. Get a string, do this
for you in here, but how about our view? Inside our view, let
me just click in here at sign a string Slash. This takes a string for me. It's the same thing for taking the string equal with
this get a string. So we have this if in here, if this is true, do this, if not, we want to say, if not, do this the next part. If it's true, this
part never runs. These codes are really
small and not line. But for learning, I think it's better that
I add a function. Anyway, even for
this, I add function. Check guess, of course, we don't have any check guess. We click on it and we
see this light bulb. We click on this light bulb
or inter. What do we have? Create function. Let's create function. It creates a private
function for me. What is this private, as we already told, this private means
you only access to it inside this game activity. So I remove this
to do and I say, let me just put an
input inside it. What's this dites? We put this inside here. Of course, do text because I want the text, do two string. And do to int. It gives me error y because this fun doesn't have any input. You see it's empty, but
you give it something. You see the next one has input, but this one doesn't. I can came here and write it
myself by hand like this. But let me just see
if I click on it and see this light
bulb or this in there. I want to show you the boot way. I have these options. I say, Okay, add it for me. Click on it. It
says, Here you are. This is in, because
we convert it to in. It says, Okay, I make it
in because you give me this in and it gives
some name to it. I don't like the name, so I just click on it
and change the name, the rest and read the
stud do it for me. So what name is good? For example, guess is good. Our guess number cams in here. You see how easy this? I don't need to return anything. If I do, I can add it in
here. You see, like this. What do we want to do?
We want to check if this guess is equal
grad or lower, then This random number. Let me just say if
inters is equals to. Remember, we have
two of these four equals two because we want
to chick a condition. If you just add one, it's four, put some other data inside
the variable or object. You put two to check if the left and the right
side is equal or not. Equals to what? Of
course, do random number. I can just close it again to arrange it for
me, just like that. If they equals,
what should I do? I want to inter, please explain it for yourself. Understand what are we doing? We even don't have to create function for
these small things. But I you understand
with these things, you arrange your code
and how do you do it? Try to make you type these
things and learn better. If it's equal, if it's
equal to our random number, I want to show our
result in here. So, I want to show
inside this txt. Txt result. But let me see, I don't have tx
result because it can understand what do you
mean by by txt result. Why? Because you see this apply, it's open in here and
it close in here. If I say txt, I have txty result in here, but You see, I don't
have it down there. Since I don't write
binding apply in here, I should write fair binding. You remember the access to our objects inside
view with view, find view by ID or binding. We do this now binding. Now I write that. I have eight gues, no, PT and go, no, I want txt. I have this three txt. Why do I write txt before
their name so I can find my text view text
views really easily. These are my rules. It's not I have two, but it's better that
you have the rules. Anyway, Tt result. So I have error.
What's the problem? Do you remember what should
we add after binding? I press on this light
ball to see I can have this question mark or this that came with
shift plus number one. This one, this one, you
see on the right side, you can see like
this or like this, like this or like this. Because it can be null? O binding can be null? We talk about it when we
declare our binding variable. Of course, it's not null. We give this we give this
nullable binding. We give this. Data, but it can be null. Because of that, let
me just go back. We have to say, It's okay. Let it go. Of course, we say what is null? Null is nothing. It's not a zero. Null isn't zero,
null is nothing. Absolutely nothing. I say, Okay, put this
question mark for me. If the red light
bulb doesn't go, I click somewhere else
and came back. It's gone. And this question mark means if it's not null to the rest. We don't have any error. As you remember, with
this question mark, we say don't run
it if it's null, but if we stay the second way, we say I'm sure it's not null. If it's null, it runs
and if gives you error. I think we should talk about this kind of errors
a little bit more. Maybe next video. So I can't be sure you
learn this part very well. Of course, you can use like
this if you check first. How can I check first? I just write if what This binding is not null,
just like that. You see how can we check, is it equal to this, we can check if
it's not equal to. I say if this binding
is not equal to null. It's, then go to the next
line and run this and I don't open and close the area because
it's just one line, but I can do this as well. I can't be sure if
I have many lines, it doesn't go to the
other lines as well and I can close it again
to sort my code like this, this line, after
that, this line, after that, the
inner part again, and finally, this one is go
one tab for there again. Anyway, as you remember, I try to never use like this, even if I can write
this kind of if. Let me just continue
in next video. So our video won't be lying. In previous video, my video became a little
bit lying because I love teaching and I
forgot about T Study. Let's continue in next video.
61. Day 9: Checking the user's guess Part3: Checking the user's
guess part three. This is our app,
and let's continue. As we just talked about, so we have this
binding and we give this value and we use it even if in this
set content view, we say like this that I'm
sure my binding isn't null. It's okay. Because
I just give this the value and I just
use this kind of. I'm sure when I just
give the value. Otherwise, question mark. But even in here it's okay that, you put question mark. So you get used to this. And you see this error. If you go up and came
down, it's gone. It's ID E b. And sometimes the IDE
itself gives you the error. You see ID internal error. We click on it. We give report to Google
and next version, these errors and bugs
became less and less. Anyway, you just press
this and Kos. Let me see. Can we learn anything
more in here? Because even if we
talk about this if, this is also possible. It's equal to that
question mark. If I don't write
this and of course, this and I just put that
question mark in here the same. I have an idea. Let me just
even comment this and go up and what happens if I didn't give this
binding the value? This set content view doesn't care if you run
this code or not. This set content
view want something. So, I didn't give this
binding the value. And I say, Okay, if I didn't give you
anything, don't run. So don't run this part, but set content view
still want something. Let me just run the app to learn a few more
things in here. My app just came up and
I want to see the log, and of course, my eye value. First, let me just
click on this game. Beginning of crash. I don't have the crash. Why? Because you see my
eye value is in here. It says only show me The logs that have my eye value,
but I don't have it. Let me just remove this. Oh, I see my errors
now. This is my error. I have my error now, in which process,
in this process. This is my package name. Even I have my process ID. Good. Look at this first line in here after this process ID. I just go, go. Of course, I see this game
activity, my game activity. It says cannot add a null
child view to a view group. You put null in here. And what else do I have? I go down. I have caused by. Not all the time, but most of the time I have these caused by. You see the text cannot add a null child view
to a view group. Let me just cannot add a null
child view to a view group. You see the same takes in here, you see down there. Most of the time, simply, I just came down to see What
is caused y. One more thing. You see you have this view group dot Java view group dot Java, line, line, line
something, line something. Those classes are for the
Android Studio cling on. What I want this
line, y, this line. Because of cose, first, this is my own package name. This is my package name. Then after my package name, I have this game activity. This is my game
activity up here. Then I have, let me
just go a little up. You see this create, I have this create. What just happened on my act on game activity on the create. And of course, I
have a link in here, game activity dot cut line 19, you have error on this line. I I just click on it, let me just go some the
risk again in here. I'm in here. I just click on it. Show me this package name, this activity, create
and exactly this line. It shows me this line. Click line 19. Set content view binding route, you have on there. If I chek Java errors, of course, they're the
places error created. But I shouldn't change them. I should fix my own activity. So I find my activity line 19, and I say what is caused
by Song is so short, this caused by and
this first line. Of course, third
line, this line, this third line
after process ID, first line, and case line, I read these two and
inside all of these texts, you can't read every line, every letter and all
of those classes. I find my own codes
and classes and I go inside my own codes to find what's wrong with my codes. This also helps me because
it says what's wrong. Most of the time, when
I want to search error, I search an error, I just go the legs and
search it or from here, from here or just this caused by search this with
some keyboard, for example, if I cannot
find the proper thing, I add some other
texts to my search. You see, if I go down down, I have even this much more. So I have lots of
data inside my error, but I show you, I just showed you these these and these are the most important
part, these three part. Let me just minimize this
and this and see this. If I write it like
this, shift one, two times or just if
I put it like this, it gives me null. It says, I can't
accept null error. If I put it like This, I won't run, because it's null. I equals nothing
because it won't run. I also have null and set
content view can't take null, and I also have error. Why? Because I don't
have error in this, I have error on my
set content view. Because I put que mark, it equals control X
with this with nothing, and it gives me error. Because I have to put something. What if I just copy this, we give the binding this data. What if I just
copy this and say, you want this data here, but not this, I should
say, dot, route. Do you remember we write root and at the end of our
previous command as well. So take the root of this game activity and put
it with this game activity, connect these two to each
other with this content view. So I think I make it right exactly this data and the root B this is
exactly like I say, Binding dot root. Exactly, I put that
data inside here, and then dot root.
Let me just see. Is it okay? Let's run
the app to see together. So I run my app, L cat. I don't have any error. Of course, first I should
press this game button. I minimize this.
My view is here. No problem. S content
view, work. It works. Now, let me just say
ten and 20 start. What just happened?
Nothing happens. Why doesn't happen? If I press this start, we should do something. If I press this start, that click lien,
should do something. And even should these
two be visible. Why isn't? Because we say if binding is null with
this question mark, doesn't do the rest
from the start of this apploy until here. PTN go and PTN a cart. Parts won't run. I press a start, but these two visibility
doesn't change. I didn't take any error. It didn't crash, but
it's not working because it ignores in these
codes and in here, these codes, and of course, the rest from the start of
apply until the end of it. All of these are ignored. Let me just check and change it. So It's null and we didn't
give anything to it. So it's null and it won't run. Let me just show you this way. Shift number one number one. It's still the old version. We should run this
again, press here. Let me just see
what just happens. I go to that game view, but my app just closed. Let me see the Log cat. I have these errors. What is it? Null pointer exception.
Do you remember? I say, you can read
caused by Cause by, which one is responsible? Who is responsible. Null pointer exception
is responsible. Where does this thing happen? Inside game activity line
55 kick inside here. Because I just say I'm
sure but it's not. You see, it's null, and what about line 25? It's the place that even
I call that function. I call my innate listener. Even when I call
this, it says, Yes, you can see and
check when you call that function and you should check where the error happens. What error null
pointer exception. I even don't have to click
on anything on that view. Why? Because in here, then create happens exactly
the time my view opens. This function called it caused the problem inside
that create and inside this, this line gives me the
error inside this function. Even I don't have to
click on anything. When create happens,
we have that error. Anyway, long story
short, you say, I'm sure it's not null, but it's null because it's null, you have null error. You might see this
in other places. It's really good to
get familiar with this and know what does
these things cause? When does this thing happens. Now just now you can
understand why I'm saying, I use only question mark. So null error. The worst thing that happened
is that thing won't run, but not crash, not error. Just as a reminder, you see I write if isn't null so run the next line like this. But why bothering ourselves? Instead of this if, just put a simple question
mark. It's better. Until here we learn so
many things and I hope you understand why question mark and what happens if it's
null and the other thing, we continue in next video, so you have this video
completely for this subject.
62. Day 9: Checking the user's guess Part4: Checking the user's guess
part four. Let's continue. We continue and uncomment this, and of course, uncomment this
change this back as well. I binding. And of
course, question mark. We have this error. We click here. Go back. We don't have any error
and read the studio bug. We talk about all of this. Let's go down. We have this check
guess and inside here, we want to remove this
as well and this part, we have this binding that
we say inside that view. We need text result. What do you want to do? With text result, text, I want the text equals, sorry, I should put this
question mark in here as well. At the end shift and the
button next to the inter. I want to inter text. As I say, your guess is true. When these things happen, when your guess is
equal to random number. You, you win. I can just say do win, for example, or not,
your guess is true. Let's fix the warning as well. We click on this light but, and as you know, we can say press
this if we say so, studio doesn't care
about this warning. Sometimes and studio
gives us warning, but we don't want to
change that part. Maybe it's because
it's an error. It's a mistake or any other take or only And with
the studio bike. If we say to press. So don't care about that. You see, I say press this and my underline
yellow color is gone. Let me just comment this. I have this under
yellow to say Yes, you have a problem in here. But if I say, let it go, say, Okay, I don't
care about this one. But I want and really
sudo care about my text. So I put it on strings. Anyway, we understand, what
is ignoring thing as well. Now, Let's continue. Let's do this again. This time we old inter
instead of to press, we do extract a string resource. So in Arabic as
well, we check it. Now, our name. Of course, I press home and say
STR under line. Why? Because I add SCR to
all the strings name. And press. I check this
Arabic as well, press k. Now, I have this g string
from where, from resource, from string fuller,
from my strings, of course, and this
is my string name. STR, your guess is true. And of course, if I put
my moe mouse on it, you can see the value. Your guess is true,
and that's default. And the Arabic, your
guess is true. You see? So I can check what is the default and what
is arabic as well. I hope you understand
all of these very well. Now, wait a second. What if it's not equal? So it isn't true. What should you do then? We say, It's equal
or less or higher. So we say I if the
first one isn't true, Now, check this if, if the first if isn't true, now, check, this if. If our random number is
bigger than what the guess? If our random number
is bigger than guess. Now we should do something. Of course, and one
back in there. Now, what should we do then? We say just control C this
one and control in here. I just came in here and I'm not going to remove all of
this and start type string. I just select this part and say, I can start typing or remove
first and say greater. Then Andrew this
studio just saying, I don't know any greater then. You don't have that string. Of course, I'm on this and then I press all
in here and I say, create this string for me. I click on it. Now, new
string value resource. Also Arabic as well, I check it. I'm just write in here. Anything you want,
you can write. But I'm saying number is greater than your guess, and I put a dot to be nicer, or even I can make this
n bigger capital n. It's up to you. So I press. And I have a
CR greater than as well. Let me just check a string, a CR greater than, I have it, and a CR Arabic number is greater
than I have it as well. Let me just close and close
as well and minimize. So I create this one as well. What e? This wasn't
true as well. I say E. Let me just
check it again. Random number is less than. You see this less than you
have it on your keyboard. If you press shift and
the button next to M. And the other one on top is
just the button after that. Not just next to M, press shift and
two button to the right next to M. You
can write this one. Let me just continue. Before I continue writing, I see this yellow line. What does it say? Let me check. I say condition random number lower than gues is always true. Why? You see you have three
situation, three options. You're either equal
Yes, I have equal. You greater than or lower than. So you check, it's not equal. You check, it's
not greater than. So it's lower than even if
you don't write this part, when it's lower then, you reach this if. So if you write this this if or not, there's
no difference. So we can simply delete it, and Andre studio also
says it's always true. If anyone reaches
here, pass these two. It's true because
it's not equal, it's not greater so it's
lower than you can remove it and it's still ok. And I
also has another warning. I put my mouse on it. It says else has empty body. What does this mean? Means you have nothing in here. It doesn't start you. It's not an error, but it says, it's better you
write something in here. But if you doesn't
write anything in here, there's no difference between these things be here or not. Let me just continue. And we just copy that line. We just paste it. Finding the series of text greater than it's just control C and control and less
than less than. Okay. Now, we also
doesn't have this. If I put my mouse on it, it also gives me this option. Create a string value
resource for this. I can click on this like this. It's the same value
arabic, of course. Well, I can just write number is less than your guess and dot. So I just press ok. The error is a still
there because ID, click here, click back. It's gone. And it's okay now. Let me just run my game to see what just happened.
What did we do? Let me minimize this
and go to the game. Now, I have first number, I say 30, and second number, I say 40, start the game. I have a number between
these two. My guess? What is my guess? I
don't put anything. I leave it blank. Please go. Please inter your guess, I have, I have error that shows me I
should put something inside. So I say let me just say
35 to see what's happened. Number is greater
than your guess. So let's go up. How about we go up than 40 41, for example. Is it good? Go. Number is less
than your guess. Of course, because
maximum is 40. 35 and 40, 37. How about that? Go.
Number is greater than. 39, 39. How about that? Number is less. Seven, 39, it's 38. 38. Good game. And if I say go, your guess is true. It is number 38. Good game, good job. We write our code and is
just great and works, and also we learn many
other things as well. I think I can teach you one
more thing in this few parts. Take user guess. These are all the
important things that we somehow should learn. Anyway, this is my
logging technique. I just show you in here. You see how can
we write our log, just like this, Control
C, I just copy this. I have this check gues. This thing is very
useful in big programs. I change it to guess
and log import class. S. Now, if guess is true, I just want to say, first thing I change this tack. For example, to s one. I sometimes put a
number at the end, so it's not complicated and doesn't get lost with the other things
inside the Android. So I put it guess one. You see, we have, for example, game activity, line 40, that we change to 87 and say guess is true g equals
guess to a string, And then I write again, just copy this random number is s random number quest string. Do you see what am I doing here? Let me just in there. So I want to check, if any time we came
inside this eve, I have some data. I want to check my
important data. As I say, in big programs, I check the problems and
other things like this. Anyway, the line,
and after that, and before that, I game
activity, of course, name. O T cutlin file lame, and then user guess it true. This is the part that
this thing happens, and then I say, Okay, the guess variable. First, I write the guess, and then I write, this is guess variable. And then I say and
this variable. It's inside. This value is
inside this variable name. Of course, I have to write that two string because in log, I have to convert
this to string. These all are my message. Let me just copy this part. Control. I really like to
teach you this as line 91. Guess Big this part
is big and of course, guess is this and
random number is this. We inside that check if we write this condition
true or not. Because if we see my random number is lower
than guess inside this, we understand that somewhere
we write something wrong. Anyway. Inter control we again, user guess is low, and of course, guess is this, random number is this. You see how good is it? I can even write a
variable name number or number of guesses
globally and add it before Or before this guess. In here, I can add it
this is first input, second input, third input, and all the other
data that I need. Then I run my program, let me just show
you that as well. C. Let's run. Let me just go to
game and, of course, clear, and control,
we check the guess, and of course, minimize this. I want to play a game. 20-30 and start, your guess. My guess is 25, go. Minimize this and zoom in twice the number is
less than your guess. Then 22, how about that? Go my guess is t. What if I say 21, go and then 22, go. Okay. Now, let me
just check Log cat. This is my guess phone logs
and dates Our minutes, seconds and even
smaller than that. So game activity,
my first action in that time is game
activity, line 87. User guess is low. Oh, I think I write
something wrong. I should change the line number. 87. Yes. Sorry about that. I should change these 295. But you see the point. Anyway, user guess is low. Guess is 25. But random number is 22. C guess is 25. So I try again. I say, guess 22. Random number is 22. Now, where were we, we are in user guess is true. Why? Because we should be inside that if guess 22,
random number 22. Anyway, I say,
Random number is 22, guess, I guess 21. Guess is bigger then. I even write this rang as well. Input. I think I
write it opposite. Anyway. But I show
you the point. I check it out as well. I do this like this. Is it very okay and then
because it's 22 and 22. Let me just clear this. And stop this as
well and minimize. In here is low because my
guess is low and here is peak. What about if I write this one wrong, for
example, opposite. When I run the app, I check it out and see, my guess is, for example, 50, my random number. Is 20 and I say greater then. I think it's wrong, and then I came in here
because I see my variable, I say, it's wrong, I came here and understand, this part, I write
this part wrong. Just like this, check our bigger programs to see
where and what is wrong. Now, if I run the up again, Now, I win the game again. Now let me just the. This is my log. Now, I came in here in line 97. My guess is low. Why? Because my guess is 35, random number is 37. I guess again, my guess is 39, random number is 37. Because of that,
my guess is big. And then I changed
this 39 to 38, is big, and then
seven, is it seven? Yes, it's 37. It's two. Now, as I say, this kind of like this of writing is when you
have a big program, you can't find where
is the problem. I write many places just
like this and don't forget. Don't write it in the places
that you don't need it. You see if you, for example, write it in here in here. The places that
you don't need it, you just waste your like place. For example, you can
do it with 100 like, but you write 500. And you waste a lot of
your time to find them. For example, in here, it's a simple code. We show error. Why should
I write any like in here? It's not reasonable. But in the places that we
have complicated situation, and I need to see different variables side by side and just a specific thing. Sometimes I use just like that. Of course, there's
other ways as well. We talk about these
ways in the future. But I think it's good to understand we have
this way as well. It's a really simple
way, as you can see. Even we don't have to use a complicated and
ready studio tool. It's a simple way and it
can be used side by side with other ways that we're
going to learn in the future. I think we can close
this taking guess part and I comment this and I
put them inside the code, so you can see how is them and if you write
anything with mistake, you can see them in
here. Thank you.
63. Day 10: Report Button Part 1: Report button, part one. So we reach the report button to show this report.
Where were we? We want to show our report
inside this text view. But first, before
this text view, let me just talk
about this gravity. First, I should change this wrap content to
match patent like this. So I have the whole area. Now I can show you
different gravities. For example, write, we be
like this on the right, or Left like this on the
left. You see the difference? How about a start and end? Let me just see. I have
different things a start. A start means left on English because English writes
from left to right. So a start in English
is left. About end. Let me just check means
right in English. Because as I say, in English, we write from left to right, so our end is right. But if we change our language, for example, in Arabic, we write from right to left. And then the end in Arabic
means left because from right to left and end
means left in Arabic. Exactly because of that, we use this end to end up, a start to sort of. These things in different
languages based on from left to right or right
to left can be different. But for now, let me
just don't talk about this constraint end to end and other things and just
talk about this gravity. So let me just say we have this in start and a little zoom out. So we should change
our view direction. So we go up in here and
we write DR direction, we change layout direction. It is right to left now. You see the difference.
Which part is different. You see this result
at the bottom. Let me just zoom Zoom
zoom a little more. Okay, this result, you
see at the moment, my results on the
right why because my layout direction is
from right to left. And the other things
based on that, here are different now. But I don't want
to show you that. I want to show you other things. So I just press inter and
say, again, direction. Sorry, I should
mention that if you just use this direction,
layout direction, you see that this text
direction has no difference, and you might get
confused because this layout direction
is for our layout. You see how layout is changed, but you want to change your text direction so
this text can be affected. So I write again the IR direction text
direction from right to left. So my text direction inside this constraint layout is now from right to left like Arabic. So if I say this text view, gravity is a start. What does a start mean? A start means the place
that you start writing. So I write from right to left. So my start is right now. Let me just change it again. Okay, we have right to left. Let me just say left to right, LTR means left to right, RTL means right to left. So left to right, you see the result goes back
at the bottom, this one. So now the text left to right, like English, left to
right, left to right. Now, my texts come to the left. Why? Because it's from left
to right, and I say, I want to start if I say, and as you can guess, it goes to the right. So if I want to write, for example, for this
text you margin. Let me just write margin margin. Margin, what I want margin
for my we, for example. This one, margin
right. How much? For example, ten DP. I have margin right, ten DPI. I have earning. I
have recommendation that it's better to
write margin end. Why margin end? Why does Andrew de
Studio said it's better to write margin
instead of margin right. You see, my right is my end now. My right in here is equal to my end because
it's left to right. Let me just show
you left to right. So it says, right end
instead of right. Why? You can understand it now because when you
change your language, if you write, when you
change your language in Arabic, write becomes left. But if you write this we, when you change your language, there is no difference in this, no difference at all. Because of that Andrew S
says it's equal to say, and it's better because if
you change your language, it changes the end change. So I think I talk about
this enough as well, and I just remove this. I think you understand about fixing these problems
in different languages. My directions
shouldn't be fixed. It should be different in
different language based on left and right
in that language. And I think you
understand the meaning of this end to end and
a start to a start. This is different in
different languages. And you see we're
at and now, yes. And if I say wrap content at the start of video, there is no different. Why? Because it's fixed. There's no left or right. There is no space to move. Because of that, I change
it to match pattern, so I can show you
what's the difference. And, of course, I go up and remove these two.
Okay, we remove this. And at the bottom, this gravity because it do nothing because of
that disrupt content, we can simply remove this as well and remove these spaces. And this look there is no
extra space and entering here. So let's go to our game
activity to continue coding. So we want to write code. And if we click on this report, when we click on this report, this should be on height. It should not be hidden anymore. This visibility
shouldn't be gone. So let me just go here. Oh, in It listener, we have this innit
listener and we have our clicks BTN start and BTN go. You can just minimize
this and minimize this as well and
press enter in here, say BTN report our third button, and press dot and set
and click listener. Inter. So what do we want to change? We want card report. Card report, check the name. This is our material card view. We don't want this.
We want the ID. This is the name Card report. So I just control
C or simply I can write card report or just
paste that Card report. This card report, we just say visibility is gone, is hidden. This is hidden. Now
I want to change it. When this button is pressed, I want to visibility be changed. I press dot my visibility, just write V and I press
Center on visibility. The first thing equals
view dot visible, remember, not a small V. You should write big
V, view dot visible. What if I forgot? Imagine I forgot
to write capital. I write a small. What just happens? Let me
just show you. I have error. So don't remember you should use capital V. This language
is case sensitive. View like this with
capital V and visible. Now, what do we want to do? In these two or three video, I think we make it three video. We want to save the things that user inputs in gas
inside our variable, somewhere, not even a variable. We want to save it somewhere in this case, inside
our variable. And after that, when
user press report, we show that data inside report. So we want to save
this value somewhere. What can we use? Do you remember we
have these variables. Just like this, we save
data inside this variable. I think we should
add range as well. Let me just add
the range as well. Inside here in here, I should press Inter and say
mean equals, for example, zero, and max is equals, that is zero as well. So we have this amin and MC and we came down in
here get random number. We have this r. We remove
this varmin and Varmax. So we have min and max. Why? Because we want to check that the user not go
out of that range. So we create this varmin
and max globally, and down here, let
me see down here, we say Min and Max
have their value. And when we want
to check guess in here in first I before that, I write if my guess
is bigger than Max or I press Shift and I press this packet slash between my packet space
and inter in my keyboard. You see if I don't press
Shift, it's like this. This. But if I write
shift, it's like this. Because I want to write or, I say two of this. Two of this means or. You write this or let
me just remove this. As I said, I guess
is bigger than max, and also guess is less than men. What should I do? I want
to tell you and of course, enter in here and
one else in here. And press delete, delete, and not delete, press
shift and now delete. Stop. I have my Ls E. So as I say, if this happens, I should just say
binding dot EDT yes, mark, D let me just show error. What is the error? Or I just write, copy this and in here
paste this string. What a string that a string, SR SR we say out of
range, out of range. I said, I have this? No, I'm not, so it gives me
error that I don't have this. So I just create
this string value. We just pause the
previous teaching because I want to add this. It's just take a few minutes. So, what should we write? Just press Arabic as well, and what should we write? Write your number
is out of range. Just like that. And press Okay. Oh, I just run my
app and press game, and I have, for example, 5,000 start the game. My guess my guess is five, it's out of range. Press go, it's out of range. If I say 5,000
something out of range, but 55 50-100, it's good. You see? So my user can't write
out of range values. I just want to add this as well. So I'm just saying
I want a variable that keeps my guest values. So in here, I press Inter
and say Why report, I think is a good name report. As you know, we can just
say it's int with Big, it's int and say it's null. Just the place we declare
and create this variable. Because if we don't
write this null, it says, you can't leave it, you should give it something. And even if I say for
now, give this null. I also says it's non null type. You can't give it null. Because of that, we
just say question mark. So it's nullable now and
we can give it null. Or simply we can
give this a value, for example, zero or
minus one. No difference. And since we have the int
and we give this a value, we don't need this int anymore because the
Android Studio, the Cartlin language itself give this report, the int type. So it makes some problems, but for now, let me
just continue this. And go to PTNg Where is RBTNo? This is RBTNg and stay
in here, press inter. I want this number. Control C in here. Sorry, inside my report. My report is equals this. So until now, we save this
value inside our edited guess. Which one? This edited
guess inside our report. So it's enough for this video, we continue in next part. So our video doesn't
get too long.
64. Day 10: Report Button Part 2: Report button, part
two. Let's continue. We reach this part
and I just write the comment and say to do. You see, it's just like
a normal comment. Why? Because I put one
space between them. Like normal to do writing, if you write to do, it's nothing, it's just a to do. It's just a simple text. But if you remove
this space like this, press built, it's different. You see this a
different color. Why? Because I write this to remind me I should came
back here later. Let me just see what did
we do in previous session? I write my Edit guess value
inside my report variable. So I can show it when
the press report button. But when we were
going to do this, I just remember I
didn't add this range. So in previous session, I add this if as well. I say, Okay, I have max. I have mean. What
is my meant max? My first value, my second
value is my range. So I want to say, my guess should be between
my mean and my max. So I say I my guess is
bigger than max, it's wrong. 00 means even if one
of these is true, go to the IO my
guess lower than me. So for example, if I say 50-100, if I write five, of course, it's not pier than 100, but this one is true. Even if one of them is
true, when you say, so I became true and my I runs from here to here
runs and my Edit guess, error became this text and
none of the rest check. Why? Because if
this if isn't true, the rest of these
checks because of this. I think I say these things a little fast and I should
explain them better. So let me see what
else? What else? This O? How can I write this or? You see, let me just
add some space. So I have this button between
my inter and packet space. If I write it, it's
look like this. You see this look like this. But if I press Shift, if it has a straight line like a column upper
than this sign. So if I press shift
on my keyboard and activate second
character in this key, press shift and
press this again. So I have this. But if I not press the shift, it's just looks like this. So I press Shift and it's okay. So let me just select
this like this. Okay, delete. So I press Shift and one, two. This means. So O, this O. This is true. Our condition is true. And even if both of them true, also our condition is true. The only situation that our if isn't run is when this is false, and this is false, as well. Only in that case, our is false and our I
isn't run this part. So let me just remove this. I think I explained
better this time. I hope you understand. And the variable, let me
just show you the variable. You see this max,
you see this mean. We define them in here so we
can globally access them. Before that, we only have
them in here locally. So outside of this, we can't access them. Because of that, I add that on the top and remove
that arb before them. So these are global now, anyway, since we came back to this go button and
checking this box, let me just add one more thing
to make it more beautiful. Better. What should we do? So if you there put the
right number, correct gas, I think it's better to, for example, killing
this, killing this, killing this, or even hide
this button, go button. You know what I mean?
Make it better game. So let me just go to code
and find my buttons. So in here, we and go. So in here, I just press
Inter and start writing. You see, we have
this to do. Why? Because we want to continue
our report button. But first, we make a few lines to make our game better
in this part of video, and then we came
back to this report. So it's really common
when you want to live apart and
later on came back, you write to do. So in input layout guesses, write dot dot what visibility. Okay, what do you want to
do with this visibility? I want to say equals
V with capital V. Do you remember if
you write lower case, it gives you error. Okay, what do you want?
I want god, hide this. So when do you want to do this? When my answer is correct? So, when this answer is correct. Here, this I is when
our answer is correct. Let me just copy the whole part. So in here, press
inter and control V and and enter and close this. So when my guess is right, height this, but
it doesn't know. Guess. Why? Because it's the
variable we have in here. So what should I do? Let
me just think about it. But let me see. Isn't my guess? Is this? Yes, it is my guess. So this is my function. So what is my guess? This is my function. I
call my function in here. So this is value I
pass into my function. So this is the guess. Edit guess, I take that text, that sing to end. This text is the
value of IDT guess. This is my guess. So I can simply just control, see the whole thing and
double click in here, you see double clicking
here and control it. So this is my guess when my guess is equal
to random number, so make it invisible. And as we can understand, we can just write this
in here down here, but let me just
continue like this. You can do this in both ways, but I just want to
do this in here. I'm not going too fast
like previous video. Let me review this.
This is my object, Edit guess, that text, it means the text inside the value of the
text of that object. So what should I
do with this text? You should make it a string, convert this text to a
string and then make it int. Why? Because you can convert to int and then check it
with random number. Why? Because this
random number is int. So you can't check
it with a string. First, you should make it int. Anyway, then inside out, if we make it visibility gone
first inter, so what else? Just I press Control D
two, duplicate this. Let me just do this again
to remove the line. Click in here anywhere here, here, and press Control and D. You have two of these. Why do I have two of these? Because you see
Input layout guess. This is our input layout guess. The whole part. We have
this button as well. So we know our BTNg name or not. If not, click on
that and see TNG. If you do just came back and
change this part to PT N. You have three PTN. PTN go and make it invisible. Let me see what else do I say? I say, Hi, this, hi this and clear clear
this, this, this. Let me just came back and
next line, I have Edit. I have Edit, first input, first value, right? First value. Most of the time I write input. It's okay. I'm not. I sometimes make mistakes. Dot that's what that text. So what should I
do with that text? I just say dot C Killer. Clear that thing. And
sometimes I by mistake, low the line like C sharp because I write other
languages as well. If you see I do this thing, for example, in previous
video, it's okay. It's my mistake. Just remove this because in cart you don't have allows line
like this. Just remove it. Anyway, what do I have? It's maybe your text is null. Okay, maybe it's null. So Question mark. If it's null, it's okay. If it's not null,
then clear that. So, is it all? No,
of course not. You just do for
Edit first value, press Control and click on it. See, Edit first value. What about the rest? Oh, you have second
number, second, and guess. So we have two more. Let me just came back
and click in here and press Control D. It's so easy. So one more Control D. So
I have two copy of that. So I just change this
part, select this part, remove it and control
a space second value. And of course, select this part, remove this control space. I have the guess as well. So clear all of them. You see, I can just go to them and double click on the name and Control C, copy and paste. But I want to show
you different ways, for example, with these
controllers space things. Before continue with this to do, let me just run the app to
see what just happened. My application runs
and again Okay, my first number is, for example, 15 and second
number is 20 start. My guess is 25, it's out of range. Go. Let me just see your number is out
of range, of course. What about if I say two Go. It's still out of range. Look, if I say 16,
greater than 17, greater than 18,
greater than how a 19, still greater than how about 20. Your guess is true, and you see where is the Gb ten? It's gone. Where is the guess? It's gone. Why? Because we write PTNO
and input layout guess. When we are right and
our guess is true, they should not be
visible anymore. And, of course, you see this box and this
box is clear now. And if I write 15 and
55 and say start, your guess is empty. Exactly because of that, I clear that as well. So I just want to
this looks better. And as I mentioned, it's not right to
write extra if when you can do this
with that other I. So it's better to write
those codes just down here, not in here, but
just write in here. To show you, you can
write it here as well. But as I say, it's
more perfessional to write it down there
with the other I. And even we can even
more perfessional, it's better to create a
function for this killer thing. Killer, killer, Killer,
invisible, invisible, clear of all of
this and something like reset all of those datas. So it's better even have
a function for that. Anyway, we don't
do this anymore, and let's continue
our report button. So we just want
to continue this. Our problem as we
just talked about, is this when we save our number, our guess inside our report, just last guess goes
to this report. Let me show you. Let me just continue and show
you what is the problem. This is the report, and
this report is a int. I just can't take one number. So we have this report, and we want this text
view to be duplicated. So just this control C, press inter and control. Simply just I remove
this label from the ID. So I have another text view, but they're on top
of each other. So let me just change this top to top of we
have top to top of, remove this part
as top to top of and say top to bottom
of bottom of what. So from your top, just connect to the bottom
of enter on that ID. And of course, this one, why is it so hard
this one, this one. Like this. And remember, if I
don't write this part, for example, let me just
select this Control X. If I don't write this
part, it's wrong. I should write this
ID part before that, just like that, and
just like this. And especially at sign Pallas, Idah the whole thing. It's the rule, it's the law. So let me just make
it match parent. And I think it's enough. Let me just continue this
discording in next video. So our video isn't
became too long.
65. Day 10: Report Button Part 3: Report button part
three. Let's continue. Okay, we save our edited guess inside our report variable, and we say it just
take one number, not a series of guesses. So let me just remove
this to continue this report part when BTN
report clicked in here, set on click listener in here. So I say TXT report dot text is equals to what the thing that we already
save this report, you see this report, we already create and in here, we give data inside that we put it inside
dotty report dot text, but there's a problem. This report is number, it's in so I should change it because this
text is a string. I just press that string. As I say, if I by mistake, close the lines like ChR, you just fill in this. Why? Because sometimes because I write CSR programs as well, I write this by mistake. Let me just run the app
and see the problem. And then came back to fix that. So let me just minimize
this, go to game, and say 15-20 and start
and my guess is, is it 15? Let me just go down, go. Yes, it's true. Okay, I can show you. It's okay. Let's start again. Sometimes happens, it's
15, it's really 15. Okay. Let me start again
and minimize this. My guess is again, 15. Go. Okay, thank God. 16. Okay, my guess is through. So 15 and 16, I enter two numbers. This time is 16. So let me just see the report, click on this and
my report is 16. But wait a minute. I just enter 15 and then 16. I should see two
numbers inside this. But I only see one number. What should I do? So
this is our problem. Because it's my last guess. So actually, it's the result because my last
guess is the result. So let me just stop this
up and minimize this. So my problem is this report can only hold one value
at the same time. Even this or even this can all of them have
only one value? What's the solution. The solution is array. Array is a series of
the same variable. So it can have many spaces. Let me just say imagine
this var variable as a box, array is a serious boxes. For example, imagine if
your array has ten slots, you can put ten
different numbers inside that and the don't do
anything with each other. Not just like this
only one number. Many different values. Where can we use? For example, in here, we want many different
values for report. User make ten guesses. We want all the ten
numbers in that series. Or for example, in a classroom, you have ten students and
you have the variable name. You don't want one name. You have the five, ten, 20 students name. And you want them all, not just one of them. You use array and many,
many other places. For example, in tables, you have many slots, and inside those
tables, you use one. Variable slot for
each table value. For example, if
you have ten row, you use ten different slots for that Before I
change it to array, let me just give you
a few more things. First, one more
example, for example, when you buy a few things in
a store and you get receipd, we can use array in
that case as well. Arrays can use many items that you purchase
on one variable. And then you can add each
of them together to have total price and
many other examples and one more thing, I forgot. Inside this text view, you see, I have this text. I shouldn't have
this text in here. If you click report, you might see this report. So what should I do to see how big or small
my text might be? I should change it to tools. I just forgot that
and we change it. So when I run my app, I won't see this text, but in here, I can see the size. This is a little important
and make it really nicer. And helps me to find it. Imagine I'm somewhere else
and I want to click on it. If this doesn't have any text, it's harder to find it. But when it does have a text, I simply click on it and it selects in here and
I can change it. Let me just show
you that as well. Select this control X. You see, I don't have it. It's gone. But if you have
this you can't find it. Now, even if you're
on somewhere else, you can find it more easily. So let's just back to our array. We have another way. What? We can make many
reports. Like what? Control DD, for example, report, report
two, report three. But there's a problem. What if my user gets 50 number? Can you imagine we add 50
report and inside our code, we give these reports one
by one, their values. No, we can't do this. Of course, it's just three. I mean, just let me
show you control, d d d d d. Many more. You can't do this. So just remove this. This is not okay. Instead of this, we use RA. This is a better example after. Even in that shop, we just write a
program for that. When, customer brings 20 items
and you want to add them, you can't create
20 different value and 20 different variable. Why? Because what
if customer brings 50 items in their basket? What do you want to
do then? You can't. Let me just remove this and go here to say this
report is, what is it? A list of a list of I want this. Let me just show you
again, clear this. If you press Inter and
have something like this, if you in here, press control
space, you have nothing. None of them is useful. Just came back one
character in here. In here, press control space. It gives you two options. You want the second one. Why? Because I want to say
it's in with Big I, as I say, if you write a small I, you have error, capital I, it's case sensitive anyway. Let me just comment
this and in next slide, write it like this. A port. What is the type? Instead of say equals of, what is the type? You see in here, we say
it's equals of this. But no, no, wait. We give the type in here. We say, y. I just want
to write this for you. List. List of what? List of Bullion, a string or It give the value.This report is array list of int
because it's integer. You see can have many
different things. For example, if I remove
this and say just string, you can have many different
string inside your report. But I want integer. And remember, these
are important tips. When you say it's int, all the arrays, spaces, all of those sections, boxes or whatever you want
to say and learn by that, all of them are the same type. So all of them at
the moment are int. You can put a
string inside them. Why? Because all of the
report sections, parts, all of them are ins and
can have only the numbers, not even the decimal. All of them are integers. So we have error.
What should we do? We should give this value. We should initialize this. Or let me just create
this for the first time. It's not B null. I say equals. Let me just write
in here equals, I have arrow array list, and just like this. What do I have? I have
error. What should I do? Let me just go in here and
space. Let me just show you. You don't have error now, but if you forgot to
press space in here, your IDE things
these two are one. These two are together and doesn't think this
as a equal sign, but makes them together. For that, I just
press this space. To say it's separate, separate this is with this
part. These are separate. If you forgot this space, that happens sometimes
you have error. Anyway, this is another way that I create this
report as an array. But the most common
way is just like this, you see, is shorter
and more simple. I have this report. What is it? Array list of int. I can create that with very, very long code, even
longer than this, it's okay, but why should I? I make it with simpler code. And since I should tell
you some different things, I try to give you more examples. Even just like this, you
remember these tools. I try to give you as much
as I can from my knowledge. So you can learn
the best way I can. I hope you not
bored because I try to teach you many
different tips and things. Anyway, let me just
show you this. I can comment this again, control the in here and
remove this part and say, No, I don't want to
give this anything. So what you we do I
want to give this null, but you can't because
it can't have null. It's okay. It can have. So it can have null, and I should give this
value in the future. I just want to show you
this can work as well. And in here, if I
remove this space, it gives me y because we don't have greater
than question mark. Do you remember we have
greater and equal. But since we don't have
great question mark, it doesn't get confused. Anyway, all the time, it's better that you
have your space. So even the IDE can understand, you don't get confused. So when I want to give this
a value, what should I do? Simply in here or
in here or in here, I should say, okay,
for example, in here, I just press inter in
here and write report, it equals array list and
we give this a value, it's not null anymore. It doesn't have
any number inside, but it's not null. And one more example, if I say int, it's grave, why? Because I say it's int already. So I don't have to
tell this again. So I don't have to use that int. Anyway, I just
remove this part and remove the extra inters and say, before I forgot,
the A A, small A. Why? Because it's
case sensitive. When I want to give
this a value like this, arraylist of it's
with a small A. But if I want to say
arrays, it's with A. Again, arrays, A, list A, a list of small A. If you, for example, in here, write a small A, you don't have that error. So it's case sensitive and
don't forget these things. I just comment this an
uncommon this list of int. I think it's easier. We can use the other thing, but I think it's
easier and better. Let me just continue this in next video so it's not too long, not became too long.
66. Day 10: Report Button Part 4: Report button, part four. Let's continue.
So we have error. What is our error? You see we just create our
array and we have error. This report is an
array list of int. But we have error. What is our error? We can put the value inside
this report like this. So what should we do? We can say, first
set this Control X, cut this, remove
this, remove this. Okay? Now, Dt. Dot add to add what add this in. This value add this with
this ard to this array. Give a new place of this
array to this value. We can use this art when we have array so I
have this arrays. So I can use this at. Let me just check to be sure. Do I have any non arrays? Yes, I have mean, I have max. Let me just use this mean. Control C, I write this mean. For example, even in here, inter mean dot at Oh, I don't have any at. You see? Why? Because that's not an array
or even in here side by side. Mean that I want to write at
just like that at, no at. Why? Because mean nuts an array. I should give the
mean value like this. Mean equals to, but no at. Remove this and extra in. Let me just run the game. Run to minimize this
and click game. I want from, for example, 15 to 20 and the
start guess 15, go. Great hair, 19, go. Less 18, go. Less about 17. Go. True. Now, show
me the report. Let me just zoom this. You see you have this
array 151-918-7017. I have 15 1918 17. I don't have just
the last number. I have the whole. So even if I enter 100
different numbers, I can have my history
and my report until now, can work like this. It's not so pretty, right? You see we just say Tix report, dot text is equal. Report dowsing. So the whole variable, the whole array, we put that
inside that Tiki report. Of course, it's not
nice and it's not a best way to do
this, but it works. And I didn't change
it so you can see what's inside your array. Of course, in future videos, we make it paper. Don't worry. Just focus and learn
all of these things. These are really
important things. We're not in very beginner, but still they are
really important. Since our game can show the
report, even like this, I think it's enough
for this video, and I think we save
very important tips. For example, one of the
most important things is we should initialize
our variable. This array should
be initialized. For example, let me just
do that one more time. If I say, let me just say A. What is it? I array
list of integer. Yes, and press N, press inter. I say a dots at,
for example, four, and if I say, what's the error, it said property
must be initialized. Exactly because of these things, you see in this example, report array list, int, we initialize this like
this equals array list. Or in here, we say our report
equals array list of Int. In all of them,
we initialize it. And if we want to say it's null, we should initialize it later. So we talk about this
initializing in different ways, and already you know
about this null. So I think you now understand
if we say null, so later, we should initialize
and make it to have a place on the
computer or phone ram. The phone is a kind of
computer, it's a computer. Anyway, on the device AM. I should have a space
for itself initialized. It's for to have a
space on the device AM for this variable
allocate space for that. L, what happens if I press
inter and say, A equals? Oh, I say, in global place, let me just cut that. I should move it
to, for example, in here, inter, and
here inside is create. That's the place to create a variable for these
kind of tests. Anyway, A array list, so if I don't write this, I just have this
small error now. Variable A must be initialized, of course, as we talk about, and then I say, A equals array list of and
then my error is gone. So I just initialize it. Why it's fixed because
it allocates this A a place on the RAMs device. No, sorry, on devices RAM. Yes. On the devices RAM. What if we just do
this, this part, Control X and remove
this in here, control we just do this in here. It says, please tell me what
does this variable type? I say, it is integer. Now, it's fixed. It's just like the
way we do something equals a list of int and you see the
difference of colors. TA is white. It's not allow boot. These are global have
different colors. You click on it and click
in here, it colors change. Sometimes I have this kind
of box you see, click click. Sometimes these things happens. Small errors, small
bugs. It's okay. Android Studio
updates and many of these things fix by itself. Maybe want to know
you can change all of these colors in setting
of Android Studio, but please don't change
many things or try to not change anything in setting until you learn a
little bit more. And if you want to change, just change the
thing you have to. When you learn more, you can make it more personal just for
you make it better. But now, you might make something change and
it doesn't work as well. You might broke it. I
shouldn't say broke it. You shouldn't change it a lot unless you learn the
setting of this Android studio. Can I add any other thing? Yes, of course, Control, for example, at six, I add two things. And even can I say this is Val? Does this give me a error Val. You see? It's okay. No error. I think I
say even more than enough and let me just
delete this and it's enough. It's enough for this video.