All language subtitles for Android-Development-for-Beginners-Full-Course_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,450 --> 00:00:04,980 Hello, everyone, and welcome to the complete\n 2 00:00:04,980 --> 00:00:10,620 is Mason. I'm a professional Android app developer.\n 3 00:00:10,619 --> 00:00:15,149 course. Before starting the course, let's\n 4 00:00:15,150 --> 00:00:20,690 is about 15 hours. And by watching it, you're\n 5 00:00:20,690 --> 00:00:26,220 But it is impossible to cover everything in\n 6 00:00:26,219 --> 00:00:30,710 version of this course, which is about 60\n 7 00:00:30,710 --> 00:00:35,460 that you need for a successful career in Android\n 8 00:00:35,460 --> 00:00:39,950 course by clicking on the link down below\n 9 00:00:39,950 --> 00:00:45,070 cover in this video. In this 15 hours, you\n 10 00:00:45,070 --> 00:00:50,539 that even if you don't have any prior experience\n 11 00:00:50,539 --> 00:00:54,789 We will cover everything in the course in\n 12 00:00:54,789 --> 00:00:59,308 up the environment that you need for Android\n 13 00:00:59,308 --> 00:01:05,179 Java Development Kit, Android Studio software\n 14 00:01:05,180 --> 00:01:10,039 and emulator for testing your applications.\n 15 00:01:10,039 --> 00:01:15,560 first section, you will create a small application\n 16 00:01:15,560 --> 00:01:20,149 and each piece in an Android application.\n 17 00:01:20,149 --> 00:01:25,629 learn Java language Java is the most popular\n 18 00:01:25,629 --> 00:01:29,959 in this section, we will take a deep look\n 19 00:01:29,959 --> 00:01:36,000 and operators, loops and conditional statements,\n 20 00:01:36,000 --> 00:01:41,938 and trading, handling exceptions Singleton\n 21 00:01:41,938 --> 00:01:48,099 about object oriented programming in Java.\n 22 00:01:48,099 --> 00:01:53,858 inner classes and abstract classes, inheritance\n 23 00:01:53,858 --> 00:01:58,089 end this section with a challenge. So to make\n 24 00:01:58,090 --> 00:02:03,539 talked about. In the next section, you will\n 25 00:02:03,539 --> 00:02:08,199 about how to design modern layouts for your\n 26 00:02:08,199 --> 00:02:13,738 about things like buttons and text views,\n 27 00:02:13,739 --> 00:02:19,879 fonts showing a list of items with ListView\n 28 00:02:19,879 --> 00:02:25,109 bars and card views, adding animations to\n 29 00:02:25,110 --> 00:02:30,070 we will talk about material design in Android.\n 30 00:02:30,069 --> 00:02:34,688 a challenge so to make sure that you have\n 31 00:02:34,688 --> 00:02:40,430 designing user interfaces, you have the ability\n 32 00:02:40,430 --> 00:02:45,379 section of this course we will create one\n 33 00:02:45,378 --> 00:02:50,030 combine all of our knowledge about Android\n 34 00:02:50,030 --> 00:02:54,659 together in this section beside practicing\n 35 00:02:54,659 --> 00:02:59,530 learn about a lot more topics. For instance,\n 36 00:02:59,530 --> 00:03:04,658 with shared preferences. And also you will\n 37 00:03:04,658 --> 00:03:08,968 application. And of course a lot more. You\n 38 00:03:08,968 --> 00:03:17,348 portfolio if you want. We are going to set\n 39 00:03:17,348 --> 00:03:22,098 create Android applications. We are going\n 40 00:03:22,098 --> 00:03:27,938 going to install Java Development Kit or as\n 41 00:03:27,938 --> 00:03:32,870 going to install Android Studio. And after\n 42 00:03:32,870 --> 00:03:38,189 device in order to test our Android applications.\n 43 00:03:38,189 --> 00:03:44,239 JDK and Android Studio. Let's also see where\n 44 00:03:44,239 --> 00:03:50,170 search for Java JDK, and a link from Oracle\n 45 00:03:50,169 --> 00:03:54,968 the Oracle web page is probably our needed\n 46 00:03:54,968 --> 00:04:01,158 and install JDK version eight, it's going\n 47 00:04:01,158 --> 00:04:06,009 down in here. First of all we need to agree\n 48 00:04:06,009 --> 00:04:10,269 depending on your operating system, you can\n 49 00:04:10,269 --> 00:04:16,358 so I'm going to download and install this\n 50 00:04:16,358 --> 00:04:23,349 this x86 or x 64, you can right click on your\n 51 00:04:23,350 --> 00:04:28,939 In here you can see the architecture of your\n 52 00:04:28,939 --> 00:04:34,439 Depending on that select one of these two\n 53 00:04:34,439 --> 00:04:39,750 download should be started. Sometimes like\n 54 00:04:39,750 --> 00:04:45,399 account. Let's do that creating an Oracle\n 55 00:04:45,399 --> 00:04:50,689 Okay, let's select Sign in. And as you can\n 56 00:04:50,689 --> 00:04:56,529 the canceling here because I have downloaded\n 57 00:04:56,529 --> 00:05:01,759 going to be a really simple installation process.\n 58 00:05:01,759 --> 00:05:08,569 Once again next. Once again, let's click on\n 59 00:05:08,569 --> 00:05:13,800 installed JDK. Let's click on this plus, if\n 60 00:05:13,800 --> 00:05:19,340 Java JDK successfully, you can always go to\n 61 00:05:19,339 --> 00:05:26,810 and typing cmd. In here, you can type Java\n 62 00:05:26,810 --> 00:05:32,780 some information about the version of Java\n 63 00:05:32,779 --> 00:05:38,159 and higher, we are good to go. Let's close\n 64 00:05:38,160 --> 00:05:45,110 download Android Studio. For that we can go\n 65 00:05:45,110 --> 00:05:51,050 During the course, we will come back to this\n 66 00:05:51,050 --> 00:05:55,819 website for Android developers. Okay, for\n 67 00:05:55,819 --> 00:06:01,519 Andrew the studio tab. And from here, you\n 68 00:06:01,519 --> 00:06:06,290 see your version of operating system, you\n 69 00:06:06,290 --> 00:06:12,159 here, I'm just going to click on the download,\n 70 00:06:12,160 --> 00:06:16,980 to agree to the terms and conditions. And\n 71 00:06:16,980 --> 00:06:21,500 Once again, I'm going to select to cancel\n 72 00:06:21,500 --> 00:06:27,269 Android Studio. After the download is finished,\n 73 00:06:27,269 --> 00:06:31,829 to be a simple installation process. Let's\n 74 00:06:31,829 --> 00:06:37,659 Android virtual device. Let's select Next\n 75 00:06:37,660 --> 00:06:44,660 Android Studio. Notice that installing Android\n 76 00:06:44,660 --> 00:06:50,730 sometimes might take something like 20 or\n 77 00:06:50,730 --> 00:06:55,831 least 20 gigabytes on the drive that you are\n 78 00:06:55,831 --> 00:07:01,470 that. Let's select Next, and install. After\n 79 00:07:01,470 --> 00:07:07,520 this next. And let's start our Android Studio.\n 80 00:07:07,519 --> 00:07:12,669 I have in here. Basically, these are the recent\n 81 00:07:12,670 --> 00:07:18,870 Studio installed on my system previously,\n 82 00:07:18,870 --> 00:07:23,939 you this list would be empty. Also along the\n 83 00:07:23,939 --> 00:07:29,459 see some windows is about selecting a theme\n 84 00:07:29,459 --> 00:07:34,899 I have installed Android Studio previously\n 85 00:07:34,899 --> 00:07:40,579 on your preferences, select one just if you\n 86 00:07:40,579 --> 00:07:46,089 that because we are going to install everything\n 87 00:07:46,089 --> 00:07:52,739 can come to this configuring here. And you\n 88 00:07:52,740 --> 00:07:58,079 software development kit. And for developing\n 89 00:07:58,079 --> 00:08:04,120 at least one SDK. Once again, as you can see,\n 90 00:08:04,120 --> 00:08:09,829 an Android nine API's both for you this list\n 91 00:08:09,829 --> 00:08:14,519 checked. First of all, let's check this show\n 92 00:08:14,519 --> 00:08:20,250 details for every SDK. By the time I'm recording\n 93 00:08:20,250 --> 00:08:27,250 is Android 10 or aka level 29. To be precise,\n 94 00:08:27,250 --> 00:08:32,690 version. But sometimes there might be some\n 95 00:08:32,690 --> 00:08:38,630 installing those because those can be buggy.\n 96 00:08:38,629 --> 00:08:44,340 channel. So make sure to install the latest\n 97 00:08:44,340 --> 00:08:50,670 the complete SDK. But I don't suggest that\n 98 00:08:50,669 --> 00:08:55,809 consuming. And these can occupy a lot of the\n 99 00:08:55,809 --> 00:09:01,669 things in here is first of all Android SDK\n 100 00:09:01,669 --> 00:09:07,899 is. So the first one, also the sources for\n 101 00:09:07,899 --> 00:09:13,110 I suggest that depending on the architecture\n 102 00:09:13,110 --> 00:09:19,820 of atom mine was 64 architecture. So I'm going\n 103 00:09:19,820 --> 00:09:25,340 with different Google API's. For example,\n 104 00:09:25,340 --> 00:09:34,310 YouTube API's, check one of these, for example,\n 105 00:09:34,309 --> 00:09:40,000 one of these two Google API versions. This\n 106 00:09:40,000 --> 00:09:47,110 system, and return or API level 29. But if\n 107 00:09:47,110 --> 00:09:53,500 SDK versions. Basically, this SDK versions\n 108 00:09:53,500 --> 00:09:58,759 Are you going to run and test your applications\n 109 00:09:58,759 --> 00:10:04,649 to run our application On a virtual device,\n 110 00:10:04,649 --> 00:10:10,209 multiple SDKs can be memory consuming and\n 111 00:10:10,210 --> 00:10:16,240 the resources, I suggest that you at least\n 112 00:10:16,240 --> 00:10:22,240 this API level 29. Because there were a lot\n 113 00:10:22,240 --> 00:10:30,669 structure also installed API level 28, down\n 114 00:10:30,669 --> 00:10:37,719 that, level, 21, and also 19. Because in this\n 115 00:10:37,720 --> 00:10:43,649 And I'm just saying this because of my experience\n 116 00:10:43,649 --> 00:10:48,799 have the proper resources, selecting one of\n 117 00:10:48,799 --> 00:10:53,620 what you need in here, just click on this\n 118 00:10:53,620 --> 00:10:58,500 connection because it's going to download\n 119 00:10:58,500 --> 00:11:03,549 here you can see a dialog that will show you\n 120 00:11:03,549 --> 00:11:08,459 going to be downloaded and also the size of\n 121 00:11:08,460 --> 00:11:13,259 and our download should be started. I'm going\n 122 00:11:13,259 --> 00:11:18,639 is finished. After the downloading and installing\n 123 00:11:18,639 --> 00:11:23,199 Before it's finished, just click on this finish.\n 124 00:11:23,200 --> 00:11:29,360 Okay, we have successfully installed at least\n 125 00:11:29,360 --> 00:11:35,060 let's see what we need from here. First of\n 126 00:11:35,059 --> 00:11:40,250 install one of these Android SDK build tools,\n 127 00:11:40,250 --> 00:11:47,090 As you can see, mine is installed in here\n 128 00:11:47,090 --> 00:11:52,910 Also down in here, you need to install Android\n 129 00:11:52,909 --> 00:11:59,179 to update that. The next two things that are\n 130 00:11:59,179 --> 00:12:04,299 SDK tools, make sure to select those two.\n 131 00:12:04,299 --> 00:12:11,019 for Android SDK. This option is not necessary,\n 132 00:12:11,019 --> 00:12:15,379 journey in Android app development. Later\n 133 00:12:15,379 --> 00:12:21,539 will help us a lot when we want to debug something\n 134 00:12:21,539 --> 00:12:26,879 suggest to install these documentations as\n 135 00:12:26,879 --> 00:12:33,080 but I suggest to install is this hexam installer,\n 136 00:12:33,080 --> 00:12:39,379 of your emulator. The native emulator in Android\n 137 00:12:39,379 --> 00:12:45,509 have a low memory Ram. For that reason, I\n 138 00:12:45,509 --> 00:12:50,460 But there is one thing that I need to mention\n 139 00:12:50,460 --> 00:12:55,500 problem with this hexam installer, I've seen\n 140 00:12:55,500 --> 00:13:01,110 them successfully. This hex m cannot be installed\n 141 00:13:01,110 --> 00:13:09,019 of your CPU, this XM might not be installed.\n 142 00:13:09,019 --> 00:13:15,838 CPUs that they have a special option in the\n 143 00:13:15,839 --> 00:13:21,710 accelerator. If that's not enabled, you may\n 144 00:13:21,710 --> 00:13:27,500 well. And also if for any reason you couldn't\n 145 00:13:27,500 --> 00:13:32,370 accelerator. And also for that matter, the\n 146 00:13:32,370 --> 00:13:38,419 to worry there is another way as well. Besides\n 147 00:13:38,419 --> 00:13:43,588 external emulators as well for example, the\n 148 00:13:43,589 --> 00:13:49,690 is called genymotion. In here, I'm not going\n 149 00:13:49,690 --> 00:13:55,240 genymotion in the description of this video.\n 150 00:13:55,240 --> 00:14:00,509 install and test your applications on the\n 151 00:14:00,509 --> 00:14:05,980 course we will see that how we can install\n 152 00:14:05,980 --> 00:14:10,950 Okay, after selecting everything from here,\n 153 00:14:10,950 --> 00:14:16,040 we are seeing the download the information\n 154 00:14:16,039 --> 00:14:20,419 Once again. I'm going to skip the video in\n 155 00:14:20,419 --> 00:14:25,049 again When the download and installing is\n 156 00:14:25,049 --> 00:14:31,069 have successfully installed SDK platforms\n 157 00:14:31,070 --> 00:14:36,250 let's switch to this appearance in here. From\n 158 00:14:36,250 --> 00:14:42,110 that you want. For example, you can change\n 159 00:14:42,110 --> 00:14:46,990 we have this high contrast theme. The intelligent\n 160 00:14:46,990 --> 00:14:52,339 with that because it's good for recording\n 161 00:14:52,339 --> 00:14:56,820 for the fonts of your Windows is from here.\n 162 00:14:56,820 --> 00:15:02,440 I'm not going to do that. Also then in here,\n 163 00:15:02,440 --> 00:15:07,781 presentation mode. If you want to change the\n 164 00:15:07,780 --> 00:15:13,528 in here, I believe it's in this editor tab\n 165 00:15:13,528 --> 00:15:20,139 is 18, you can increase or decrease that if\n 166 00:15:20,139 --> 00:15:24,939 let's minimize this editor. I have another\n 167 00:15:24,940 --> 00:15:31,180 appearance inside the system settings inside\n 168 00:15:31,179 --> 00:15:36,778 being checked from a stable channel. We have\n 169 00:15:36,778 --> 00:15:42,960 betha channels as well make sure that you\n 170 00:15:42,960 --> 00:15:48,190 Okay, that's it for installing SDK, we will\n 171 00:15:48,190 --> 00:15:54,550 on. Let's select OK. OK, now it's time to\n 172 00:15:54,549 --> 00:15:59,838 can once again select this configure this\n 173 00:15:59,839 --> 00:16:05,839 stands for Android virtual device. As you\n 174 00:16:05,839 --> 00:16:11,250 in here pixel two and pixel three, this list\n 175 00:16:11,250 --> 00:16:16,669 Android Studio installed on my system, I can\n 176 00:16:16,669 --> 00:16:22,269 in order to create a new virtual device. First\n 177 00:16:22,269 --> 00:16:28,590 the hardware by selecting this new hardware\n 178 00:16:28,590 --> 00:16:34,430 you can select that if it's a phone or tablet,\n 179 00:16:34,429 --> 00:16:40,479 Also then in here you can specify some ram\n 180 00:16:40,480 --> 00:16:47,190 I'm not going to create my customized device.\n 181 00:16:47,190 --> 00:16:52,760 devices. As you can see, I have pixel two\n 182 00:16:52,759 --> 00:16:59,639 device from here. Also from this left panel,\n 183 00:16:59,639 --> 00:17:05,048 and tablets. Let's select one device from\n 184 00:17:05,048 --> 00:17:10,788 Let's just select this pixel Excel, select\n 185 00:17:10,788 --> 00:17:16,158 the Android version that is going to be installed\n 186 00:17:16,159 --> 00:17:22,089 q or API level 29 on this device, so we need\n 187 00:17:22,088 --> 00:17:26,619 once again, I think it's going to be a large\n 188 00:17:26,619 --> 00:17:32,158 here until the download is finished. Yes,\n 189 00:17:32,159 --> 00:17:37,170 installing is finished just click on Finish.\n 190 00:17:37,170 --> 00:17:42,110 you might not see the version of API that\n 191 00:17:42,109 --> 00:17:47,118 you can always refer to this list. After that,\n 192 00:17:47,118 --> 00:17:54,178 third tab. But we are going to install Android\n 193 00:17:54,179 --> 00:17:58,940 we can customize our device. For example,\n 194 00:17:58,940 --> 00:18:04,649 also change the default orientation. For example,\n 195 00:18:04,648 --> 00:18:11,648 its portrait. In this Show advanced settings,\n 196 00:18:11,648 --> 00:18:17,699 you can change the camera, the network. Also\n 197 00:18:17,700 --> 00:18:24,319 and SD card and all sorts of customization.\n 198 00:18:24,319 --> 00:18:29,980 just going to click on this finish. And as\n 199 00:18:29,980 --> 00:18:34,839 on our device. Okay, let's close this window.\n 200 00:18:34,839 --> 00:18:40,488 off this video. In this video, we have installed\n 201 00:18:40,489 --> 00:18:45,579 After that we have installed SDK and we have\n 202 00:18:45,579 --> 00:18:53,908 And after everything we have installed a new\nvirtual device. 203 00:18:53,909 --> 00:18:59,980 We are going to create our first application\n 204 00:18:59,980 --> 00:19:04,798 selecting this start a new Android Studio\n 205 00:19:04,798 --> 00:19:10,868 can see some templates. These templates are\n 206 00:19:10,868 --> 00:19:16,009 codes written to some level. For example,\n 207 00:19:16,009 --> 00:19:21,028 have a small button and also a menu above\n 208 00:19:21,028 --> 00:19:27,249 for example, a template for Google Maps, we\n 209 00:19:27,249 --> 00:19:32,610 worry about all of these because we will learn\n 210 00:19:32,609 --> 00:19:39,008 later on. Even we select this ad no activity\n 211 00:19:39,009 --> 00:19:45,618 and they have provided us these templates.\n 212 00:19:45,618 --> 00:19:50,129 word activity Don't worry about this activity\n 213 00:19:50,130 --> 00:19:55,389 I said that we are going to have an entire\n 214 00:19:55,388 --> 00:20:00,429 and fragments. But for now you can think of\n 215 00:20:00,430 --> 00:20:04,999 application. For example, if your application\n 216 00:20:04,999 --> 00:20:11,460 those pages, this definition is not accurate,\n 217 00:20:11,460 --> 00:20:17,129 we can think of an activity as a page of our\n 218 00:20:17,128 --> 00:20:21,849 going to save it this empty activity, which\n 219 00:20:21,849 --> 00:20:27,959 some files for us. But if you want to save\n 220 00:20:27,960 --> 00:20:32,399 Once again, later on, we will see that how\n 221 00:20:32,398 --> 00:20:37,408 Okay, let's select empty activity. And let's\n 222 00:20:37,409 --> 00:20:43,169 information about our application. For example,\n 223 00:20:43,169 --> 00:20:49,770 change the name of my application to let's\n 224 00:20:49,769 --> 00:20:56,089 to name their first project, I level just\n 225 00:20:56,089 --> 00:21:01,918 the package name for your application. This\n 226 00:21:01,919 --> 00:21:06,799 that is being released into the world. later\n 227 00:21:06,798 --> 00:21:13,119 to play store, your application will be identified\n 228 00:21:13,119 --> 00:21:18,508 here is to provide the name of your website\n 229 00:21:18,509 --> 00:21:25,819 maker.org. So my package name is or dot maker\n 230 00:21:25,819 --> 00:21:29,700 you don't have any website, if you don't,\n 231 00:21:29,700 --> 00:21:37,919 Let's say comm dot example dot the name of\n 232 00:21:37,919 --> 00:21:43,899 going to use that in here, I'm going to say\n 233 00:21:43,898 --> 00:21:49,459 be unique to every application. After that,\n 234 00:21:49,460 --> 00:21:54,639 to save your project. If you want, you can\n 235 00:21:54,638 --> 00:22:00,699 in here and select the path but in here, I'm\n 236 00:22:00,700 --> 00:22:06,230 select the language that you're going to work\n 237 00:22:06,230 --> 00:22:11,419 with Java language, and also kotlin language.\n 238 00:22:11,419 --> 00:22:17,759 Java. But if you want, I am currently recording\n 239 00:22:17,759 --> 00:22:24,319 with kotlin. Feel free to check that if you\n 240 00:22:24,319 --> 00:22:30,168 that, you need to define a minimum API level.\n 241 00:22:30,169 --> 00:22:35,570 how many older Android devices can install\n 242 00:22:35,569 --> 00:22:41,028 on this drop down in here, you can see the\n 243 00:22:41,028 --> 00:22:48,109 minimum API level that I can select these\n 244 00:22:48,109 --> 00:22:53,928 10. To be precise, there is a balance in here.\n 245 00:22:53,929 --> 00:23:00,950 high, you can work with a lot of newer functionalities\n 246 00:23:00,950 --> 00:23:06,519 to install your Android applications. For\n 247 00:23:06,519 --> 00:23:13,048 the latest version, only less than 1% of the\n 248 00:23:13,048 --> 00:23:21,038 something like 19, we can see that 95% of\n 249 00:23:21,038 --> 00:23:26,690 you as the developer should decide this balance\n 250 00:23:26,690 --> 00:23:33,409 stay with API level 19 for most of our projects,\n 251 00:23:33,409 --> 00:23:41,289 is a good number. Leave this check empty for\n 252 00:23:41,288 --> 00:23:46,720 since few months ago, we will talk about it\n 253 00:23:46,720 --> 00:23:52,339 let's create our first project. If it's the\n 254 00:23:52,339 --> 00:23:58,249 applications, this process can be very slow\n 255 00:23:58,249 --> 00:24:04,569 some stuff, for example, the gradle file from\n 256 00:24:04,569 --> 00:24:10,019 can be slow if it's the first time that you\n 257 00:24:10,019 --> 00:24:16,450 in here that is noticeable is that Android\n 258 00:24:16,450 --> 00:24:22,740 activity main dot XML file, and this main\n 259 00:24:22,740 --> 00:24:28,259 because we have selected that empty activity\n 260 00:24:28,259 --> 00:24:33,028 Inside each of these files. There are some\n 261 00:24:33,028 --> 00:24:37,989 codes if we don't select that empty activity.\n 262 00:24:37,989 --> 00:24:45,380 codes written to some level. The other thing\n 263 00:24:45,380 --> 00:24:51,359 build painting here will show the progress\n 264 00:24:51,358 --> 00:24:56,418 you want to run your Android application,\n 265 00:24:56,419 --> 00:25:03,809 will be working in our entire course. Whether\n 266 00:25:03,808 --> 00:25:08,628 here will show the progress of building your\n 267 00:25:08,628 --> 00:25:13,778 it for now. And let's talk about all the other\n 268 00:25:13,778 --> 00:25:20,009 all, let's talk about this project thing here,\n 269 00:25:20,009 --> 00:25:25,858 here, we have multiple options. For example,\n 270 00:25:25,858 --> 00:25:32,319 option view exactly shows the structure of\n 271 00:25:32,319 --> 00:25:38,298 maximize every folder. If you want to have\n 272 00:25:38,298 --> 00:25:45,898 you can go to App folder inside the sources.\n 273 00:25:45,898 --> 00:25:52,969 you can see that we have a folder in here,\n 274 00:25:52,970 --> 00:25:58,279 This is the exact hierarchy of files on our\n 275 00:25:58,279 --> 00:26:04,971 you can right click on the name of your project\n 276 00:26:04,971 --> 00:26:11,940 here, it will open the Explorer on your Windows,\n 277 00:26:11,940 --> 00:26:18,379 don't worry about the others inside this project.\n 278 00:26:18,378 --> 00:26:25,449 this app folder. Inside this app folder, we\n 279 00:26:25,450 --> 00:26:32,440 org, may code HelloWorld. And this is the\n 280 00:26:32,440 --> 00:26:38,009 project view will show the exact hierarchy\n 281 00:26:38,009 --> 00:26:43,210 another view in here and that's called Android\n 282 00:26:43,210 --> 00:26:47,999 for the most of this course, because it's\n 283 00:26:47,999 --> 00:26:54,009 can see, we have this app folder. And inside\n 284 00:26:54,009 --> 00:27:00,200 package name. And inside that we have this\n 285 00:27:00,200 --> 00:27:05,909 easy for eyes to follow different files. Also,\n 286 00:27:05,909 --> 00:27:11,590 scripts down in here as well. Before I talk\n 287 00:27:11,589 --> 00:27:17,959 about the structure of every Android application.\n 288 00:27:17,960 --> 00:27:23,548 at least two different kinds of files, the\n 289 00:27:23,548 --> 00:27:29,249 of your application. The layout files in Android\n 290 00:27:29,249 --> 00:27:35,860 main dot XML file. If you click on that, you\n 291 00:27:35,859 --> 00:27:41,978 now it has only one simple text. The other\n 292 00:27:41,979 --> 00:27:47,808 file. If you are developing in kotlin language,\n 293 00:27:47,808 --> 00:27:54,148 file in most cases will define the logic of\n 294 00:27:54,148 --> 00:27:59,978 if you click on a button, or what to do with\n 295 00:27:59,979 --> 00:28:06,479 in the Java or kotlin files. Beside the layout\n 296 00:28:06,479 --> 00:28:12,750 There might be some other files, for example,\n 297 00:28:12,750 --> 00:28:19,569 files as well. Those will be inside this Resources\n 298 00:28:19,569 --> 00:28:25,788 Right now we have an icon for our application,\n 299 00:28:25,788 --> 00:28:31,788 images or other files can be put inside this\n 300 00:28:31,788 --> 00:28:38,839 Resources folder is for the static variables\n 301 00:28:38,839 --> 00:28:44,488 are the three main components of every Android\n 302 00:28:44,489 --> 00:28:51,090 Java file, and also we have the static files.\n 303 00:28:51,089 --> 00:28:58,189 the manifest folder. This manifest file Vila\n 304 00:28:58,190 --> 00:29:02,690 application. For example, you can see the\n 305 00:29:02,690 --> 00:29:07,720 can see the name of your application, which\n 306 00:29:07,720 --> 00:29:13,440 properties or features about your application.\n 307 00:29:13,440 --> 00:29:18,259 on in the course. But for now, let's close\n 308 00:29:18,259 --> 00:29:23,829 every Android application. But for example,\n 309 00:29:23,829 --> 00:29:29,819 from the Play Store, you will see that we\n 310 00:29:29,819 --> 00:29:35,308 final application that will be released, how\n 311 00:29:35,308 --> 00:29:41,058 in that case, this Gradle tooling here is\n 312 00:29:41,058 --> 00:29:48,069 that will combine all of these files and other\n 313 00:29:48,069 --> 00:29:53,329 matter if you want to release your application\n 314 00:29:53,329 --> 00:29:59,739 an emulator, you are going to need Gradle\n 315 00:29:59,739 --> 00:30:06,119 with The other use of Gradle is that if you\n 316 00:30:06,118 --> 00:30:12,378 as well, for example, if you want to use YouTube\n 317 00:30:12,378 --> 00:30:19,069 inside this built up gradle file down in here,\n 318 00:30:19,069 --> 00:30:25,319 download the code for YouTube video player,\n 319 00:30:25,319 --> 00:30:31,028 player code to your project. And after that,\n 320 00:30:31,028 --> 00:30:37,528 that will handle the combination of every\n 321 00:30:37,528 --> 00:30:43,329 an APK file, we will talk about different\n 322 00:30:43,329 --> 00:30:48,499 let's close all of these extra files. Okay,\n 323 00:30:48,499 --> 00:30:54,048 or maximize this pain from here. Let's minimize\n 324 00:30:54,048 --> 00:30:59,740 in Android Studio. Then in here, you have\n 325 00:30:59,740 --> 00:31:05,919 to do is very helpful when you are creating\n 326 00:31:05,919 --> 00:31:11,340 to those are some works that you don't want\n 327 00:31:11,339 --> 00:31:17,459 those works. For example, inside this main\n 328 00:31:17,460 --> 00:31:20,058 I can say to do, let's say complete 329 00:31:20,058 --> 00:31:26,079 this. It's just for the developers to remind\n 330 00:31:26,079 --> 00:31:32,019 later on. As you can see this to do has been\n 331 00:31:32,019 --> 00:31:37,450 want, you can check that it says that it's\n 332 00:31:37,450 --> 00:31:43,389 talk about how we can define to dues and also\n 333 00:31:43,388 --> 00:31:48,998 the other pains. The other one is this terminal\n 334 00:31:48,999 --> 00:31:55,819 prompt in Windows or let's say terminal in\n 335 00:31:55,819 --> 00:32:01,079 working with something like ADB or Android\n 336 00:32:01,079 --> 00:32:08,189 of ADB in our projects. Also, it's very useful\n 337 00:32:08,190 --> 00:32:13,109 worked extensively with this terminal in the\n 338 00:32:13,108 --> 00:32:18,538 new tool here we have seen it when we have\n 339 00:32:18,538 --> 00:32:23,960 of every application when it's going to be\n 340 00:32:23,960 --> 00:32:30,169 problem when we build our project. And from\n 341 00:32:30,169 --> 00:32:35,059 After that we have this logcat in here, it's\n 342 00:32:35,058 --> 00:32:40,509 to debug our Android applications. In fact,\n 343 00:32:40,509 --> 00:32:46,368 at Okay, let's minimize all of these for now.\n 344 00:32:46,368 --> 00:32:53,449 File, Edit view and all of these, we will\n 345 00:32:53,450 --> 00:32:59,109 but it's impossible to work with all of them.\n 346 00:32:59,108 --> 00:33:04,468 in here. When you create your first application,\n 347 00:33:04,469 --> 00:33:10,369 rendering warning or some other kind of warning,\n 348 00:33:10,368 --> 00:33:14,798 wrong with your application, you just need\n 349 00:33:14,798 --> 00:33:19,918 come to this build option in here and make\n 350 00:33:19,919 --> 00:33:25,149 some errors at the first time that you create\n 351 00:33:25,148 --> 00:33:31,609 of Android Studio can be buggy. And creating\n 352 00:33:31,609 --> 00:33:37,238 problem. Also, there is another option from\n 353 00:33:37,239 --> 00:33:43,700 and reopen it that can be useful or in some\n 354 00:33:43,700 --> 00:33:50,159 and restart Android Studio. So if you get\n 355 00:33:50,159 --> 00:33:55,989 three different ways in order to overcome\n 356 00:33:55,989 --> 00:34:02,308 that has been added to Android Studio recently\n 357 00:34:02,308 --> 00:34:09,019 Android profiler. Let's add that to this pane.\n 358 00:34:09,019 --> 00:34:15,588 to this view to Windows and profiler, it's\n 359 00:34:15,588 --> 00:34:21,378 that your application is using, for example,\n 360 00:34:21,378 --> 00:34:27,429 is using, or even the amount of network that\n 361 00:34:27,429 --> 00:34:33,418 application, we can track the live amount\n 362 00:34:33,418 --> 00:34:38,658 is going to use. Let's run our application\n 363 00:34:38,659 --> 00:34:44,278 by clicking on this green triangle from here,\n 364 00:34:44,278 --> 00:34:50,639 app that you're working. And also beside that\n 365 00:34:50,639 --> 00:34:56,838 video we have created a virtual device and\n 366 00:34:56,838 --> 00:35:04,338 available. I'm going to run my application\n 367 00:35:04,338 --> 00:35:09,818 let's just run. If we click on this building\n 368 00:35:09,818 --> 00:35:16,940 that even if you are going to debug your application,\n 369 00:35:16,940 --> 00:35:23,760 at the production process, you can check the\n 370 00:35:23,760 --> 00:35:30,069 this emulator has been opened. And we will\n 371 00:35:30,068 --> 00:35:35,550 from down in here, you can see the current\n 372 00:35:35,550 --> 00:35:41,670 now it has created or built my application\n 373 00:35:41,670 --> 00:35:47,068 to turn on. Also, if you check this logcat\n 374 00:35:47,068 --> 00:35:53,079 of things going on in here. We will be using\n 375 00:35:53,079 --> 00:35:59,631 for different debugging purposes. Let's minimize\n 376 00:35:59,630 --> 00:36:06,170 will see the live tracks of different resources\n 377 00:36:06,170 --> 00:36:12,838 our emulator. Right now we have this simple\n 378 00:36:12,838 --> 00:36:20,588 called hello world. And if you want, you can\n 379 00:36:20,588 --> 00:36:22,078 resources that your application is 380 00:36:22,079 --> 00:36:27,609 using, it's going to be helpful when you're\n 381 00:36:27,608 --> 00:36:33,288 is using. Let's minimize that for now. If\n 382 00:36:33,289 --> 00:36:39,910 this red button here, you can stop it. And\n 383 00:36:39,909 --> 00:36:47,489 By long pressing this turn off button, you\n 384 00:36:47,489 --> 00:36:51,899 shut down. As you can see, we are getting\n 385 00:36:51,900 --> 00:36:58,528 not important. But if you want to check them,\n 386 00:36:58,528 --> 00:37:05,068 that happens since we click on this green\n 387 00:37:05,068 --> 00:37:10,338 let's minimize that. And let's switch back\n 388 00:37:10,338 --> 00:37:16,699 have a lot of options in here as well. Right\n 389 00:37:16,699 --> 00:37:22,710 application. This white one is called the\n 390 00:37:22,710 --> 00:37:28,869 view. There are some slight differences between\n 391 00:37:28,869 --> 00:37:35,240 item inside your activity that might not be\n 392 00:37:35,239 --> 00:37:40,649 keep track of that inside the blueprint view.\n 393 00:37:40,650 --> 00:37:46,099 view because we are not going to work with\n 394 00:37:46,099 --> 00:37:52,079 you can click on this stack icon. And you\n 395 00:37:52,079 --> 00:37:59,670 and maximize that by pressing this plus button.\n 396 00:37:59,670 --> 00:38:05,869 elements different user interface or UI elements.\n 397 00:38:05,869 --> 00:38:12,250 your application, you can simply drag it like\n 398 00:38:12,250 --> 00:38:17,588 application. As you can see right now because\n 399 00:38:17,588 --> 00:38:23,639 attributes. At the right panel, we have a\n 400 00:38:23,639 --> 00:38:30,480 element. The most important one is this ID\n 401 00:38:30,480 --> 00:38:35,829 your element in which we will use it in order\n 402 00:38:35,829 --> 00:38:42,240 from inside of Java file. Later on, we will\n 403 00:38:42,239 --> 00:38:47,969 you can see that we have different attributes\n 404 00:38:47,969 --> 00:38:52,089 If you want to check the list of all of the\n 405 00:38:52,090 --> 00:38:58,970 all attributes. And you can see that there\n 406 00:38:58,969 --> 00:39:05,000 with different UI elements in the UI session\n 407 00:39:05,000 --> 00:39:11,349 now, after the Java session we will be talking\n 408 00:39:11,349 --> 00:39:18,420 Also, when you are inside your XML file, you\n 409 00:39:18,420 --> 00:39:24,200 view is this view that we are working right\n 410 00:39:24,199 --> 00:39:31,779 can see the exact value of every UI element\n 411 00:39:31,780 --> 00:39:37,910 you are a web developer, you know the concept\n 412 00:39:37,909 --> 00:39:44,929 language. markup languages are just for defining\n 413 00:39:44,929 --> 00:39:49,618 example, a button or text view, you can see\n 414 00:39:49,619 --> 00:39:54,838 but that the don't know anything about them\n 415 00:39:54,838 --> 00:40:02,039 in the force. So there are two ways of defining\n 416 00:40:02,039 --> 00:40:08,400 for example, a button to your design view,\n 417 00:40:08,400 --> 00:40:13,440 can see that we have a button in here, we\n 418 00:40:13,440 --> 00:40:18,240 press Delete, and that button will be deleted,\n 419 00:40:18,239 --> 00:40:23,929 Also, if you don't have this preview enabled,\n 420 00:40:23,929 --> 00:40:29,279 Ctrl Z in order to get back our button. And\n 421 00:40:29,280 --> 00:40:35,160 going to define an ID for this Hello text\n 422 00:40:35,159 --> 00:40:40,288 going to identify that and I'm going to work\n 423 00:40:40,289 --> 00:40:46,730 can see the list of attributes. At the top,\n 424 00:40:46,730 --> 00:40:52,088 TextView. Also, if you don't know the difference\n 425 00:40:52,088 --> 00:40:58,048 these don't be very TextView is just a fancy\n 426 00:40:58,048 --> 00:41:03,420 the ID whatever you want. For example, in\n 427 00:41:03,420 --> 00:41:08,950 that there are some conventions in here, you\n 428 00:41:08,949 --> 00:41:15,018 an ID also beside that you can't use some\n 429 00:41:15,018 --> 00:41:20,608 sign. The other convention in here is that\n 430 00:41:20,608 --> 00:41:26,548 For example, this team here is learn cases.\n 431 00:41:26,548 --> 00:41:32,619 first letter of the second word. in capital\n 432 00:41:32,619 --> 00:41:38,929 there are some just basic conventions among\n 433 00:41:38,929 --> 00:41:44,989 an ID for this hello world. If we switch back\n 434 00:41:44,989 --> 00:41:51,058 see that for this TextView, an attribute has\n 435 00:41:51,059 --> 00:41:56,280 what you do inside your TextView or design\n 436 00:41:56,280 --> 00:42:01,590 you can see, right now we have some warning\n 437 00:42:01,590 --> 00:42:07,160 button is not constrained to anywhere. That's\n 438 00:42:07,159 --> 00:42:12,730 for this whole XML file. Don't worry about\n 439 00:42:12,730 --> 00:42:18,260 like relative layout and linear layouts as\n 440 00:42:18,260 --> 00:42:23,160 are using constraint layout, which is the\n 441 00:42:23,159 --> 00:42:28,710 application, you need to concentrate or chain\n 442 00:42:28,710 --> 00:42:34,280 if I don't constrain this button to anywhere,\n 443 00:42:34,280 --> 00:42:40,390 Because of the different screen sizes, we\n 444 00:42:40,389 --> 00:42:45,460 of this button. And right now if we run our\n 445 00:42:45,460 --> 00:42:51,599 moved to the place zero and zero, which is\n 446 00:42:51,599 --> 00:42:58,269 to overcome this warning, we can simply add\n 447 00:42:58,269 --> 00:43:06,679 As simple as that I'm constraining this button\n 448 00:43:06,679 --> 00:43:11,710 top and the bottom, I can constraint that\n 449 00:43:11,710 --> 00:43:17,679 that to this TextView. For the button, I'm\n 450 00:43:17,679 --> 00:43:24,250 screen. As you can see whenever I add a constraint,\n 451 00:43:24,250 --> 00:43:30,268 in here as well. Now we don't have that red\n 452 00:43:30,268 --> 00:43:36,298 when we have created this button, when we\n 453 00:43:36,298 --> 00:43:42,269 ID has been added to it as well. The idea\n 454 00:43:42,269 --> 00:43:48,949 that if you want. For example, I can say btn\n 455 00:43:48,949 --> 00:43:57,338 in an XML file, the ID should be a specific\nto every element. 456 00:43:57,338 --> 00:44:02,259 Right now this button doesn't do anything.\n 457 00:44:02,260 --> 00:44:07,778 a little bit more interactive. For example,\n 458 00:44:07,778 --> 00:44:13,588 by clicking on this button. For that we need\n 459 00:44:13,588 --> 00:44:18,849 that we could have access to its attributes.\n 460 00:44:18,849 --> 00:44:23,798 going to switch to full screen so that you\n 461 00:44:23,798 --> 00:44:28,858 in here. If you go to this view option in\n 462 00:44:28,858 --> 00:44:33,838 that we have few options. I'm going to go\n 463 00:44:33,838 --> 00:44:38,808 i'm going to stay with full screen. Okay,\n 464 00:44:38,809 --> 00:44:43,471 file. As I said in the previous video, you\n 465 00:44:43,471 --> 00:44:49,039 here. And that's because when we created our\n 466 00:44:49,039 --> 00:44:55,288 project for that now we have an empty activity\n 467 00:44:55,289 --> 00:45:00,740 also main activity dot java file. In future\n 468 00:45:00,739 --> 00:45:05,989 folds if we select no activity at the time\n 469 00:45:05,989 --> 00:45:11,399 these codes returned to this level. Also,\n 470 00:45:11,400 --> 00:45:16,849 import. If you click on that, you can see\n 471 00:45:16,849 --> 00:45:22,609 class. If you want, you can always minimize\n 472 00:45:22,608 --> 00:45:27,108 you can minimize and maximize all of your\n 473 00:45:27,108 --> 00:45:32,210 imports like this so that we can see what\n 474 00:45:32,210 --> 00:45:37,210 be worried about all of the new keywords that\n 475 00:45:37,210 --> 00:45:42,300 class extends protected void. We will talk\n 476 00:45:42,300 --> 00:45:48,000 But for now, just know that this onCreate\n 477 00:45:48,000 --> 00:45:52,420 application, it means that when we run our\n 478 00:45:52,420 --> 00:45:58,588 braces is going to be the code that will run\n 479 00:45:58,588 --> 00:46:03,400 method that we used. We will talk about that\n 480 00:46:03,400 --> 00:46:08,139 method, two things are happening, we have\n 481 00:46:08,139 --> 00:46:13,129 talk about that right now. And after that\n 482 00:46:13,130 --> 00:46:18,809 content views we are accessing to the activity\n 483 00:46:18,809 --> 00:46:24,660 main in here. Basically it means that this\n 484 00:46:24,659 --> 00:46:29,319 main layout file. We will talk in more depth\n 485 00:46:29,320 --> 00:46:34,818 now just know that up until this point in\n 486 00:46:34,818 --> 00:46:39,719 is related to this layout file. After that,\n 487 00:46:39,719 --> 00:46:45,739 example, in here, I'm going to access to that\n 488 00:46:45,739 --> 00:46:50,949 video for that I can say text view. As you\n 489 00:46:50,949 --> 00:46:56,349 the idea behind the Android Studio is suggesting\n 490 00:46:56,349 --> 00:47:01,929 here, but the one that I need is going to\n 491 00:47:01,929 --> 00:47:08,048 Java, we have classes equivalent to the UI\n 492 00:47:08,048 --> 00:47:13,768 layout file. If we are going to define a button\n 493 00:47:13,768 --> 00:47:19,119 here we are going to use text view. So we\n 494 00:47:19,119 --> 00:47:24,429 you can see, a new line of code has been added\n 495 00:47:24,429 --> 00:47:31,088 the TextView from the widget package into\n 496 00:47:31,088 --> 00:47:35,670 The name is optional, and you can name it\n 497 00:47:35,670 --> 00:47:41,309 going to say txt Hello, this is just the basic\n 498 00:47:41,309 --> 00:47:46,190 you want, but we will talk about conventions\n 499 00:47:46,190 --> 00:47:50,769 TextView you need to locate the TextView from\n 500 00:47:50,768 --> 00:47:55,939 that is like this, you can say is equal to\n 501 00:47:55,940 --> 00:48:02,170 that is useful for finding different views\n 502 00:48:02,170 --> 00:48:08,338 view by ID. Once again, this method is useful\n 503 00:48:08,338 --> 00:48:13,818 elements from your layout files by date ID\n 504 00:48:13,818 --> 00:48:18,820 need to pass the ID of our TextView from inside\n 505 00:48:18,820 --> 00:48:24,539 like this, we can type r r is a special class\n 506 00:48:24,539 --> 00:48:31,028 all of our resources, our static files in\n 507 00:48:31,028 --> 00:48:38,369 let's select that, you can say r.id dot after\n 508 00:48:38,369 --> 00:48:44,809 have which was txt message, I believe this\n 509 00:48:44,809 --> 00:48:50,540 have put inside your layout file for this\n 510 00:48:50,539 --> 00:48:56,568 And we are using that to have access to our\n 511 00:48:56,568 --> 00:49:02,210 view by ID method, and after that passing\n 512 00:49:02,210 --> 00:49:07,519 our text view. But you can see that there\n 513 00:49:07,518 --> 00:49:13,518 in Java, every time you write a sentence,\n 514 00:49:13,518 --> 00:49:18,618 That's just syntactical and it really doesn't\n 515 00:49:18,619 --> 00:49:23,329 semicolon, but in Java, you need to put a\n 516 00:49:23,329 --> 00:49:29,180 now up to this point, we have our TextView\n 517 00:49:29,179 --> 00:49:33,960 if we want to change the text of our TextView\n 518 00:49:33,960 --> 00:49:39,269 the name of our TextView which is txt Hello.\n 519 00:49:39,268 --> 00:49:44,199 this dot operator. We will talk about it in\n 520 00:49:44,199 --> 00:49:50,179 for now just know that when you are typing.on\n 521 00:49:50,179 --> 00:49:55,268 and attributes. For example in here I can\n 522 00:49:55,268 --> 00:50:00,118 have multiple options. Let's import the first\n 523 00:50:00,119 --> 00:50:05,140 You need to pass a text. And whenever you're\n 524 00:50:05,139 --> 00:50:10,710 you're going to hard code the text, you need\n 525 00:50:10,710 --> 00:50:16,159 pass a double quotation inside this double\n 526 00:50:16,159 --> 00:50:21,230 Now we have changed the text of our TextView.\n 527 00:50:21,230 --> 00:50:27,318 going to work. Remember that inside our activity\n 528 00:50:27,318 --> 00:50:32,798 Inside our Java file, we are changing it to\n 529 00:50:32,798 --> 00:50:38,018 see, in here, the text of our TextView has\n 530 00:50:38,018 --> 00:50:42,969 is not interactive, we want to change the\n 531 00:50:42,969 --> 00:50:48,549 we run the application. For that we need to\n 532 00:50:48,550 --> 00:50:53,900 onClick listener for this button so that when\n 533 00:50:53,900 --> 00:50:59,048 changes, there are multiple ways of defining\n 534 00:50:59,048 --> 00:51:04,400 one is to do that inside your main activity\n 535 00:51:04,400 --> 00:51:10,710 your button element inside the anchor brackets\n 536 00:51:10,710 --> 00:51:15,269 can see that we have an option in here. Let's\n 537 00:51:15,268 --> 00:51:21,929 to say on btn clique, this name in here is\n 538 00:51:21,929 --> 00:51:26,848 file. As you can see, right now we are getting\n 539 00:51:26,849 --> 00:51:32,359 method in your Java file. Let's copy the name\n 540 00:51:32,358 --> 00:51:37,960 and create that method. So in order to create\n 541 00:51:37,960 --> 00:51:44,030 scope of this onCreate method. And inside\n 542 00:51:44,030 --> 00:51:48,980 about this, we need to define our method inside\n 543 00:51:48,980 --> 00:51:54,769 this, we can say public void after that the\n 544 00:51:54,768 --> 00:51:59,768 a pair of parentheses, because it's going\n 545 00:51:59,768 --> 00:52:04,629 we need to accept a viewing here, don't worry\n 546 00:52:04,630 --> 00:52:09,849 all of these in Java session. Let's name this\n 547 00:52:09,849 --> 00:52:15,500 braces for our method. And in here, we need\n 548 00:52:15,500 --> 00:52:21,980 the user clicks on our button. If you switch\n 549 00:52:21,980 --> 00:52:27,858 you can see that the red error has been disappeared.\n 550 00:52:27,858 --> 00:52:33,380 I'm going to change the text of our TextView\n 551 00:52:33,380 --> 00:52:39,480 So for that method, I'm going to move these\n 552 00:52:39,480 --> 00:52:44,369 can probably guess the behavior of our application\n 553 00:52:44,369 --> 00:52:48,990 how is it going to work. You can see that\n 554 00:52:48,989 --> 00:52:54,419 click on our button, the text will change\n 555 00:52:54,420 --> 00:53:00,269 what we want. It's just saying hello right\n 556 00:53:00,268 --> 00:53:05,979 For example, we are going to get the name\n 557 00:53:05,980 --> 00:53:10,719 going to say for example Hello may sound Hello\n 558 00:53:10,719 --> 00:53:17,259 get the user's input, the way to get the user's\n 559 00:53:17,259 --> 00:53:23,000 edit text. Let's switch to design view. You\n 560 00:53:23,000 --> 00:53:28,028 going to this text option in here, you can\n 561 00:53:28,028 --> 00:53:33,608 one is for text view, we have seen the text\n 562 00:53:33,608 --> 00:53:39,449 we have other options, plaintext, password,\n 563 00:53:39,449 --> 00:53:44,919 for when you want to get different kinds of\n 564 00:53:44,920 --> 00:53:49,809 we are going to use plain text. Plain Text\n 565 00:53:49,809 --> 00:53:55,180 get from the user. Let's drag that into our\n 566 00:53:55,179 --> 00:54:00,118 in here, you can see that it's ID is edit\n 567 00:54:00,119 --> 00:54:07,759 EDT. txt name. Because we are inside the constraint\n 568 00:54:07,759 --> 00:54:12,798 text as well. But before that, I'm going to\n 569 00:54:12,798 --> 00:54:19,030 I am going to change its constraint from the\n 570 00:54:19,030 --> 00:54:24,240 editors. For that I am going to direct the\n 571 00:54:24,239 --> 00:54:29,098 of this edit text. Now let's add some other\n 572 00:54:29,099 --> 00:54:35,130 example, for the top, I'm going to constrain\n 573 00:54:35,130 --> 00:54:40,619 for the edges. I'm going to go to the edges\n 574 00:54:40,619 --> 00:54:45,630 our text view. If you want we can add some\n 575 00:54:45,630 --> 00:54:52,070 say 70. That seems to be better. The other\n 576 00:54:52,070 --> 00:54:56,730 text in here. I'm talking about this attribute\n 577 00:54:56,730 --> 00:55:01,519 name if you want you can change that but in\n 578 00:55:01,518 --> 00:55:07,029 instead, I'm going to define some hints. You\n 579 00:55:07,030 --> 00:55:13,140 between hint and text is that when you click\n 580 00:55:13,139 --> 00:55:19,028 It's just a hint for the user to know that\n 581 00:55:19,028 --> 00:55:23,730 edit text. For example, in here, I'm going\n 582 00:55:23,730 --> 00:55:29,719 out. Okay, now we have an edit text inside\n 583 00:55:29,719 --> 00:55:35,038 to have access to this edit text so that we\n 584 00:55:35,039 --> 00:55:40,880 start point of our activity. And our application\n 585 00:55:40,880 --> 00:55:47,259 inside this onCreate method, we can have access\n 586 00:55:47,259 --> 00:55:52,949 We can say Edit Text. Once again, you can\n 587 00:55:52,949 --> 00:55:57,439 edit text as well. Also, if you take a look\n 588 00:55:57,440 --> 00:56:03,829 code has been added to our class as well.\n 589 00:56:03,829 --> 00:56:09,358 before, we can say is equal to find view by\n 590 00:56:09,358 --> 00:56:16,679 of our edit text which I can say r.id dot\n 591 00:56:16,679 --> 00:56:22,848 our edit text. Now, we need to get the text\n 592 00:56:24,338 --> 00:56:29,440 dot get text, you can see that we have this\n 593 00:56:29,440 --> 00:56:34,579 to do another level of conversion. And we\n 594 00:56:34,579 --> 00:56:39,460 this two string method yet, we will talk about\n 595 00:56:39,460 --> 00:56:45,108 converting whatever the text is inside our\n 596 00:56:45,108 --> 00:56:49,650 Java file. Don't worry about that. We will\n 597 00:56:49,650 --> 00:56:54,769 with our code in here, we are going to get\n 598 00:56:54,769 --> 00:56:59,509 to the user. When we click on the button.\n 599 00:56:59,509 --> 00:57:04,719 text inside our on button click method. But\n 600 00:57:04,719 --> 00:57:10,899 say Edit Text name, you can see that everything\n 601 00:57:10,900 --> 00:57:15,920 to that edit text inside this method. And\n 602 00:57:15,920 --> 00:57:21,190 Java. The scope of this edit text is this\n 603 00:57:21,190 --> 00:57:26,700 this onCreate method, we can have access to\n 604 00:57:26,699 --> 00:57:31,159 method. In order to solve that problem, we\n 605 00:57:31,159 --> 00:57:36,838 our on button click method. Let's quickly\n 606 00:57:36,838 --> 00:57:41,980 let's paste them. But right now we are not\n 607 00:57:41,980 --> 00:57:46,929 getting the user's input, but you're not doing\n 608 00:57:46,929 --> 00:57:52,889 of code to the set text method. Let's quickly\n 609 00:57:52,889 --> 00:57:58,690 of the set text method. I'm going to pass\n 610 00:57:58,690 --> 00:58:05,278 get text.to string. This way, we are setting\n 611 00:58:05,278 --> 00:58:10,119 is inside our edit text. Let's quickly run\n 612 00:58:10,119 --> 00:58:14,910 This is how our application and this edit\n 613 00:58:14,909 --> 00:58:20,379 you can see that we can type something for\n 614 00:58:20,380 --> 00:58:26,420 on our button, the text of our text view changes\n 615 00:58:26,420 --> 00:58:32,059 we want to say hello to myself. In order to\n 616 00:58:32,059 --> 00:58:37,480 code. Also notice that I didn't put any double\n 617 00:58:37,480 --> 00:58:43,500 passing this text dynamically to our set text\n 618 00:58:43,500 --> 00:58:47,239 we need to put that inside double quotation\n 619 00:58:47,239 --> 00:58:52,529 if we want to say hello to the user, we can\n 620 00:58:52,530 --> 00:58:58,440 quotation, let's add a plus in here. And inside\n 621 00:58:58,440 --> 00:59:03,940 let's add a space so that we could see everything\n 622 00:59:03,940 --> 00:59:09,119 in programming, adding the two texts together,\n 623 00:59:09,119 --> 00:59:14,608 let's type something in here. Let's say Mesa\n 624 00:59:14,608 --> 00:59:22,929 that the text has been changed to allow Mesa\n 625 00:59:22,929 --> 00:59:28,639 Okay, this is our challenge, we are going\n 626 00:59:28,639 --> 00:59:34,028 are going to get the user's first name, last\n 627 00:59:34,028 --> 00:59:39,179 button, we are going to show them inside these\n 628 00:59:39,179 --> 00:59:47,018 about. So if we have a first name, last name,\n 629 00:59:47,018 --> 00:59:51,739 button, we are going to show them inside these\n 630 00:59:51,739 --> 00:59:56,529 application so that we can practice everything\n 631 00:59:56,530 --> 01:00:01,190 you to pause the video in here and create\n 632 01:00:01,190 --> 01:00:07,079 it, come back to the video and we are going\n 633 01:00:07,079 --> 01:00:11,200 I hope you solve the challenge but if not,\n 634 01:00:11,199 --> 01:00:16,199 that in here together. Also notice that whenever\n 635 01:00:16,199 --> 01:00:21,058 of recent projects in the left panel in here.\n 636 01:00:21,059 --> 01:00:26,249 project we can say start a new Android Studio\n 637 01:00:26,248 --> 01:00:31,338 this empty activity. Let's name our project\n 638 01:00:31,338 --> 01:00:38,038 or Let's name it registration for you need\n 639 01:00:38,039 --> 01:00:43,009 the Save location if you want. And also I'm\n 640 01:00:43,009 --> 01:00:48,260 create our project. Let's start by creating\n 641 01:00:48,260 --> 01:00:53,119 jellified for now. And let's also minimize\n 642 01:00:53,119 --> 01:00:57,559 this HelloWorld text, you can click on it\n 643 01:00:57,559 --> 01:01:03,510 in our registration form, we needed to edit\n 644 01:01:03,510 --> 01:01:08,900 need to add three plain texts in here. Let's\n 645 01:01:08,900 --> 01:01:14,710 on. Don't worry about that right now through\n 646 01:01:14,710 --> 01:01:20,289 add that as well. We also needed three text\n 647 01:01:20,289 --> 01:01:26,910 Let's also change the IDs. For the first one,\n 648 01:01:26,909 --> 01:01:33,598 also delete this text and also add something.\n 649 01:01:33,599 --> 01:01:39,730 thing for the other two edit texts. Sometimes\n 650 01:01:39,730 --> 01:01:44,240 attribute for your elements, you can see some\n 651 01:01:44,239 --> 01:01:49,639 avoid that by pressing the Escape key on your\n 652 01:01:49,639 --> 01:01:56,299 let's change its ID to let's say btn register.\n 653 01:01:56,300 --> 01:02:01,990 delete this text. And let's say register.\n 654 01:02:01,989 --> 01:02:07,038 attribute in here, we can define an onClick\n 655 01:02:07,039 --> 01:02:12,369 we did in the previous video in our TextView.\n 656 01:02:12,369 --> 01:02:17,989 let's say on Register btn. Click later on,\n 657 01:02:17,989 --> 01:02:23,019 First of all, let's change their IDs. For\n 658 01:02:23,018 --> 01:02:30,048 first name. Also, let's change the text to\n 659 01:02:30,048 --> 01:02:35,108 and let's greatly constraint all of these\n 660 01:02:35,108 --> 01:02:40,808 one, I'm going to constraint it to the top\n 661 01:02:40,809 --> 01:02:47,230 my screen. Let's also add a margin top of\n 662 01:02:47,230 --> 01:02:53,429 next one, I'm going to constraint it to the\n 663 01:02:53,429 --> 01:02:58,739 also to the bottom of my first name edit text,\n 664 01:02:58,739 --> 01:03:04,179 same thing for this email. For the button,\n 665 01:03:04,179 --> 01:03:09,558 probably change the top constraint. Also,\n 666 01:03:09,559 --> 01:03:15,019 your elements, you can click on the constraint\n 667 01:03:15,019 --> 01:03:21,829 constraint, let's change the top constraint\n 668 01:03:21,829 --> 01:03:27,239 name, I'm going to constraint it to the both\n 669 01:03:27,239 --> 01:03:33,789 just try once again. And also the top constraint\n 670 01:03:33,789 --> 01:03:40,239 once again, let's say 90, I think 90 is fine.\n 671 01:03:40,239 --> 01:03:47,260 now we are not seeing our last name TextView.\n 672 01:03:47,260 --> 01:03:53,519 name, I'm going to do the same thing. Let's\n 673 01:03:53,518 --> 01:03:59,868 say 24. Same thing for the email. Okay, this\n 674 01:03:59,869 --> 01:04:04,420 And now that we have defined our layout file,\n 675 01:04:04,420 --> 01:04:09,559 the behavior of our application, I'm going\n 676 01:04:09,559 --> 01:04:14,859 everything, let's just copy this onClick attribute\n 677 01:04:14,858 --> 01:04:20,409 define this method in our Java file. In our\n 678 01:04:20,409 --> 01:04:27,288 package folder inside our main activity dot\n 679 01:04:27,289 --> 01:04:32,880 Once again, I can say public void the name\n 680 01:04:32,880 --> 01:04:38,180 file, inside the parentheses, I need to say\n 681 01:04:38,179 --> 01:04:43,808 Lord v. And now I have created my own button\n 682 01:04:43,809 --> 01:04:48,730 about the syntax of this method. We will talk\n 683 01:04:48,730 --> 01:04:54,568 Java in here. First of all I'm going to define\n 684 01:04:54,568 --> 01:05:00,849 like this. We can say TextView for the first\n 685 01:05:00,849 --> 01:05:10,450 view by ID r.id dot txt. Firstly, I'm going\n 686 01:05:10,449 --> 01:05:15,518 after you have defined your text views, it's\n 687 01:05:15,518 --> 01:05:20,429 that like this, we can say Edit Text. For\n 688 01:05:20,429 --> 01:05:27,690 name is equal to find view by ID r.id dot\n 689 01:05:27,690 --> 01:05:33,608 to do the same thing for edit text, email\n 690 01:05:33,608 --> 01:05:38,889 have access to all of the UI elements that\n 691 01:05:38,889 --> 01:05:43,400 text views. For example, for the txt first\n 692 01:05:43,400 --> 01:05:48,889 say txt first name. That's a text. We have\n 693 01:05:48,889 --> 01:05:55,699 in here. Let's say first name, plus the text\n 694 01:05:55,699 --> 01:06:02,778 Text first name, dot get text.to string. As\n 695 01:06:02,778 --> 01:06:08,980 of our text view to the text of our edit text.\n 696 01:06:08,980 --> 01:06:17,139 email. Edit Text last name, that's a text.\n 697 01:06:17,139 --> 01:06:25,018 text last name dot get text.to string, edit\n 698 01:06:25,018 --> 01:06:31,778 the wrong element in here. This should be\n 699 01:06:31,778 --> 01:06:34,679 Same thing for the email, txt email. 700 01:06:34,679 --> 01:06:43,379 That's it text. Let's say email plus edit\n 701 01:06:43,380 --> 01:06:48,430 all we need from our application. Let's just\n 702 01:06:48,429 --> 01:06:53,358 good job with the layout of our application.\n 703 01:06:53,358 --> 01:06:58,018 top of this register button and also these\n 704 01:06:58,018 --> 01:07:03,848 all of them better. Let's also test its behavior\n 705 01:07:03,849 --> 01:07:10,269 last name, let's say Watson for the email,\n 706 01:07:10,268 --> 01:07:15,659 register button. And as you can see, we are\n 707 01:07:15,659 --> 01:07:23,690 our application is working perfectly. In this\n 708 01:07:23,690 --> 01:07:31,099 about Java for writing Java applications,\n 709 01:07:31,099 --> 01:07:37,620 development environment. Android Studio has\n 710 01:07:37,619 --> 01:07:43,278 few months ago, you could have right and drawn\n 711 01:07:43,278 --> 01:07:48,798 I think it was around July 2019, that you\n 712 01:07:48,798 --> 01:07:53,759 of a new release in Gradle. I have recorded\n 713 01:07:53,759 --> 01:07:58,849 And it's on my YouTube channel. If you want\n 714 01:07:58,849 --> 01:08:03,680 on YouTube and you will probably find a video\n 715 01:08:03,679 --> 01:08:08,149 that I'm talking about. Andrew the sudo does\n 716 01:08:08,150 --> 01:08:13,430 do now. And you can also see my channel name,\n 717 01:08:13,429 --> 01:08:18,329 basically what I was talking about in that\n 718 01:08:18,329 --> 01:08:24,670 you need to use another ID. The most famous\n 719 01:08:24,670 --> 01:08:30,000 are Eclipse and IntelliJ. In this course,\n 720 01:08:30,000 --> 01:08:35,869 a lot like Android Studio. And also it's free.\n 721 01:08:35,869 --> 01:08:41,390 intelligent Id make sure to check that if\n 722 01:08:41,390 --> 01:08:47,039 Studio beside intelligent, you're going to\n 723 01:08:47,039 --> 01:08:52,930 already installed on our system, you can get\n 724 01:08:52,930 --> 01:08:58,720 say intelligent ID. The first link from the\n 725 01:08:58,720 --> 01:09:03,480 Just one thing that was mentioning here is\n 726 01:09:03,479 --> 01:09:08,789 version and also an ultimate version, the\n 727 01:09:08,789 --> 01:09:13,210 for our needs in this course. So make sure\n 728 01:09:13,210 --> 01:09:19,100 it and also installed it come back to this\n 729 01:09:19,100 --> 01:09:24,400 installed on my system and I'm going to open\n 730 01:09:24,399 --> 01:09:29,539 in here by saying create new project. As you\n 731 01:09:29,539 --> 01:09:35,989 Studio, I have the ultimate version of intelligence\n 732 01:09:35,989 --> 01:09:40,689 These might not be available for you if you're\n 733 01:09:40,689 --> 01:09:45,379 version you're using, you should see this\n 734 01:09:45,380 --> 01:09:51,199 need to specify the path to your JDK. If you\n 735 01:09:51,199 --> 01:09:56,269 of this course you should be good in here\n 736 01:09:56,270 --> 01:10:02,670 my version in here is 13. But we are not going\n 737 01:10:02,670 --> 01:10:07,579 Oracle does not support this version of Java\n 738 01:10:07,579 --> 01:10:13,529 of the features of Java eight. Okay, After\n 739 01:10:13,529 --> 01:10:18,689 click next, we are not going to create our\n 740 01:10:18,689 --> 01:10:24,469 this option. After that, click Next. In here,\n 741 01:10:24,470 --> 01:10:30,140 a location for the name of this project. I'm\n 742 01:10:30,140 --> 01:10:35,700 see these settings in here, you have this\n 743 01:10:35,699 --> 01:10:40,720 that your module name is exactly your project\n 744 01:10:40,720 --> 01:10:45,260 location if you need, I'm not going to change\n 745 01:10:45,260 --> 01:10:51,100 let's create our project. As you can see,\n 746 01:10:51,100 --> 01:10:56,600 And the reason for that once again is that\n 747 01:10:56,600 --> 01:11:01,410 Let's just close this tip dialog. And let's\n 748 01:11:01,409 --> 01:11:07,229 full screen mode. Once again, in IntelliJ\n 749 01:11:07,229 --> 01:11:12,619 minimize and maximize that you can also move\n 750 01:11:12,619 --> 01:11:18,269 use any template our folders are empty, we\n 751 01:11:18,270 --> 01:11:23,930 on the source folder by right clicking on\n 752 01:11:23,930 --> 01:11:28,940 a package for our application. In this case,\n 753 01:11:28,939 --> 01:11:36,099 dot let's say hello world. And inside this\n 754 01:11:36,100 --> 01:11:39,880 worry about the term class that are used.\n 755 01:11:39,880 --> 01:11:44,470 oriented session. But for now just know that\n 756 01:11:44,470 --> 01:11:49,630 in order to run our Java applications. By\n 757 01:11:49,630 --> 01:11:55,180 new Java class we can create our class Let's\n 758 01:11:55,180 --> 01:12:00,130 new Java class has been created in our package.\n 759 01:12:00,130 --> 01:12:05,159 minimize our project pane. Let's focus on\n 760 01:12:05,159 --> 01:12:10,720 we have in here is the package that we are\n 761 01:12:10,720 --> 01:12:15,720 And also we have the declaration of a class\n 762 01:12:15,720 --> 01:12:20,829 later on in future videos. In order to have\n 763 01:12:20,829 --> 01:12:25,779 going to need at least one method and that\n 764 01:12:25,779 --> 01:12:32,670 to create that method we can type p SVM. By\n 765 01:12:32,670 --> 01:12:37,250 As you can see, this green triangle has been\n 766 01:12:37,250 --> 01:12:42,250 our application from this point, we will talk\n 767 01:12:42,250 --> 01:12:47,439 later on in the course. But for now, just\n 768 01:12:47,439 --> 01:12:52,899 you need at least one Java class in which\n 769 01:12:52,899 --> 01:12:58,589 is like the onCreate method of our activities.\n 770 01:12:58,590 --> 01:13:02,930 method. For example, in order to print something\n 771 01:13:02,930 --> 01:13:09,130 this we can say s o UT or south and by pressing\n 772 01:13:09,130 --> 01:13:14,880 System dot out dot print line. Or alternatively,\n 773 01:13:14,880 --> 01:13:20,510 the shortcut, you can say system, notice that\n 774 01:13:20,510 --> 01:13:27,921 to use the upper case for us. Let's say system\n 775 01:13:27,921 --> 01:13:32,750 here it means that we are going to add 14\n 776 01:13:32,750 --> 01:13:37,530 something later on we will see that we have\n 777 01:13:37,530 --> 01:13:43,510 input. Let's say System dot out dot print\n 778 01:13:43,510 --> 01:13:48,030 line. For now we are going to use the print\n 779 01:13:48,029 --> 01:13:53,250 on. In order to print something to the console,\n 780 01:13:53,250 --> 01:13:58,270 you can say something like this. For example,\n 781 01:13:58,270 --> 01:14:03,370 simplest Java application that can be written,\n 782 01:14:03,369 --> 01:14:08,800 to run our Java application for the first\n 783 01:14:08,800 --> 01:14:15,750 braces of our main method and select Run hello.me.\n 784 01:14:15,750 --> 01:14:20,310 hello world into our console. Sometimes if\n 785 01:14:20,310 --> 01:14:25,640 applications, you may get some errors in here.\n 786 01:14:25,640 --> 01:14:32,140 by rebuilding your project, you can come to\n 787 01:14:32,140 --> 01:14:36,670 project. After the rebuild is finished, you\n 788 01:14:36,670 --> 01:14:41,960 clicking and selecting run. Hello, that's\n 789 01:14:41,960 --> 01:14:47,399 But if you had any other problem, please ask\n 790 01:14:47,399 --> 01:14:52,029 notice that for the rest of this section,\n 791 01:14:52,029 --> 01:14:57,909 it is possible to have a graphical user interface\n 792 01:14:57,909 --> 01:15:03,729 this is an Android course and later We've\n 793 01:15:03,729 --> 01:15:08,669 we are not going to use any user interface\n 794 01:15:08,670 --> 01:15:13,789 to understand the language. Okay, now let's\n 795 01:15:13,789 --> 01:15:18,109 talk about the difference between print and\n 796 01:15:18,109 --> 01:15:23,229 print line is that when you are using print\n 797 01:15:23,229 --> 01:15:28,669 will move to the next line. That is not the\n 798 01:15:28,670 --> 01:15:35,270 let's say System dot out dot print. Once again,\n 799 01:15:35,270 --> 01:15:39,350 run our application to see the difference.\n 800 01:15:39,350 --> 01:15:43,789 to run your application, you can right click\n 801 01:15:43,789 --> 01:15:48,899 Hello dot main. Or if it's not the first time,\n 802 01:15:48,899 --> 01:15:53,899 left or the green triangle. On the top of\n 803 01:15:53,899 --> 01:15:59,629 for Windows is shift plus fn. If you're using\n 804 01:15:59,630 --> 01:16:03,460 triangle and see the shortcut. Let's run the\n 805 01:16:03,460 --> 01:16:08,069 print and print line, you can see that the\n 806 01:16:08,069 --> 01:16:13,039 moved to the next line. If we switch these\n 807 01:16:14,039 --> 01:16:19,310 let's switch now. Now print line is the first\n 808 01:16:19,310 --> 01:16:23,520 the application once again. This time, you\n 809 01:16:23,520 --> 01:16:28,360 in two separate lines. Okay, now that we know\n 810 01:16:28,359 --> 01:16:32,809 let's talk about variables in Java. But before\n 811 01:16:32,810 --> 01:16:37,900 lines of code, you can comment them by pressing\n 812 01:16:37,899 --> 01:16:42,699 in Java, it means that you are telling the\n 813 01:16:42,699 --> 01:16:48,510 The use of comment is for developers to remind\n 814 01:16:48,510 --> 01:16:54,659 important. For example, in here I can say\n 815 01:16:54,659 --> 01:16:59,319 line of code will be completely ignored. The\n 816 01:16:59,319 --> 01:17:05,909 we can say slash slash to do after that we\n 817 01:17:05,909 --> 01:17:10,269 of comment with to do at the beginning of\n 818 01:17:10,270 --> 01:17:15,500 the color will be changed to blue. And also\n 819 01:17:15,500 --> 01:17:20,229 can see that you have one to do in your file.\n 820 01:17:20,229 --> 01:17:24,939 multiple programmers. By clicking on this\n 821 01:17:24,939 --> 01:17:29,089 tools. There are more to comments, we will\n 822 01:17:29,090 --> 01:17:33,840 for now just know that when you're commenting\n 823 01:17:33,840 --> 01:17:39,500 Okay, now let's talk about variables. Variables\n 824 01:17:39,500 --> 01:17:45,710 data in your job application. For example,\n 825 01:17:45,710 --> 01:17:51,050 are useful for when you want to store some\n 826 01:17:51,050 --> 01:17:55,510 if you want to store a number or a text, if\n 827 01:17:55,510 --> 01:18:01,520 like this. You can say int int stands for\n 828 01:18:01,520 --> 01:18:06,820 store whole numbers for example, negative\n 829 01:18:06,819 --> 01:18:10,939 to define them is like this. First of all,\n 830 01:18:10,939 --> 01:18:15,409 your variable. For example, in here, I can\n 831 01:18:15,409 --> 01:18:21,099 And you can use whatever you want. After that\n 832 01:18:21,100 --> 01:18:27,460 example, I can say five in here, this is the\n 833 01:18:27,460 --> 01:18:34,069 name of my variable. And this five is the\n 834 01:18:34,069 --> 01:18:39,349 you can also have negative numbers. After\n 835 01:18:39,350 --> 01:18:43,350 some operation on them, for example, you can\n 836 01:18:43,350 --> 01:18:48,220 this, you can say System dot out dot print\n 837 01:18:48,220 --> 01:18:53,060 or whatever is the name of your variable.\n 838 01:18:53,060 --> 01:18:58,289 quotation. Basically, whenever you are passing\n 839 01:18:58,289 --> 01:19:03,350 devil quotation but whenever you're passing\n 840 01:19:03,350 --> 01:19:08,310 quotation, let's run the application and see\n 841 01:19:08,310 --> 01:19:13,660 the value of our number is negative five in\n 842 01:19:13,659 --> 01:19:19,960 have decimal values. For example, in here,\n 843 01:19:19,960 --> 01:19:25,560 in which you can use in order to store decimal\n 844 01:19:25,560 --> 01:19:30,760 The other kind of variable that you can use\n 845 01:19:30,760 --> 01:19:36,829 see that as well. We can see a long, you can\n 846 01:19:36,829 --> 01:19:42,269 say five. Let's also print that, let's say\n 847 01:19:42,270 --> 01:19:47,500 our log. If we run the application, you can\n 848 01:19:47,500 --> 01:19:54,100 long and integer is that you can store larger\n 849 01:19:54,100 --> 01:20:00,160 will store more spaces in your device's memory\n 850 01:20:00,159 --> 01:20:06,039 store numbers as large as the number of two\n 851 01:20:06,039 --> 01:20:11,479 can store numbers as long as the number of\n 852 01:20:11,479 --> 01:20:16,909 between long and integer. But what if you\n 853 01:20:16,909 --> 01:20:22,559 numbers for that you have other kinds of variables,\n 854 01:20:22,560 --> 01:20:29,650 we can say double, let's name it my double.\n 855 01:20:31,729 --> 01:20:37,269 let's pass our data. If we run the application,\n 856 01:20:37,270 --> 01:20:41,890 can see that down in here. So double is one\n 857 01:20:41,890 --> 01:20:47,750 to store floating point numbers. The other\n 858 01:20:47,750 --> 01:20:53,560 well. We can say float, let's name it my float.\n 859 01:20:53,560 --> 01:20:58,560 name your variables, whatever you want, we\n 860 01:20:58,560 --> 01:21:02,940 now you can see that we are getting a read\n 861 01:21:02,939 --> 01:21:08,139 point numbers by default are double in Java,\n 862 01:21:08,140 --> 01:21:13,520 number, you need to cast your number to float,\n 863 01:21:13,520 --> 01:21:19,190 After the equal, we can open and close a parentheses\n 864 01:21:19,189 --> 01:21:24,579 by casting, you will explicitly tell the ID\n 865 01:21:24,579 --> 01:21:31,130 not a double number. Okay, let's quickly print\n 866 01:21:31,130 --> 01:21:35,829 run the application, you can see that once\n 867 01:21:35,829 --> 01:21:41,710 difference between float and double is that\n 868 01:21:41,710 --> 01:21:47,890 And also the other difference is in the space\n 869 01:21:47,890 --> 01:21:53,520 in the device's memory. Basically double view\n 870 01:21:53,520 --> 01:21:58,790 that much in this course, I just wanted to\n 871 01:21:58,789 --> 01:22:04,269 now we have seen numbers. But what if we want\n 872 01:22:04,270 --> 01:22:10,500 that we have a special kind of variable which\n 873 01:22:10,500 --> 01:22:18,020 char is equal to, let's say M. Notice that\n 874 01:22:18,020 --> 01:22:22,870 variable, I have used this single quotation\n 875 01:22:22,869 --> 01:22:27,769 different numbers. When you're assigning a\n 876 01:22:27,770 --> 01:22:34,350 like before we can print our character. Let's\n 877 01:22:34,350 --> 01:22:39,870 You can see em printed in here. When you're\n 878 01:22:39,869 --> 01:22:43,789 characters. For example, in here, I can't\n 879 01:22:43,789 --> 01:22:48,640 error. In order to store multiple characters,\n 880 01:22:48,640 --> 01:22:52,810 we will talk about that in a minute. But before\n 881 01:22:52,810 --> 01:22:57,910 more thing. You can also store something like\n 882 01:22:57,909 --> 01:23:05,500 u 00. A, this is a special Unicode value for\n 883 01:23:05,500 --> 01:23:09,810 and see what would be the result, you can\n 884 01:23:09,810 --> 01:23:15,350 printed into our console. When you're using\n 885 01:23:15,350 --> 01:23:20,039 values as well. You can search for different\n 886 01:23:20,039 --> 01:23:26,029 show the copyright symbol, we can say something\n 887 01:23:26,029 --> 01:23:30,729 If you've run the application, we should see\n 888 01:23:30,729 --> 01:23:35,980 other Unicode values on the internet. Okay,\n 889 01:23:35,980 --> 01:23:40,599 to restore multiple characters, we can use\n 890 01:23:40,600 --> 01:23:46,600 S. After that, like before, we can name our\n 891 01:23:46,600 --> 01:23:54,400 it name is equal to Mesa meaning like before,\n 892 01:23:54,399 --> 01:23:59,619 fascinate and let's run the application, we\n 893 01:23:59,619 --> 01:24:04,409 console. But you may have noticed that there\n 894 01:24:04,409 --> 01:24:09,939 string is not blue, like the other kinds of\n 895 01:24:09,939 --> 01:24:13,919 difference between a string and other kinds\n 896 01:24:13,920 --> 01:24:19,630 that we have talked about so far are primitive\n 897 01:24:19,630 --> 01:24:25,079 do we have talked about classes and objects\n 898 01:24:25,079 --> 01:24:30,460 you are using a class, you can have some operations\n 899 01:24:30,460 --> 01:24:35,710 can say dot and you can see a list of different\n 900 01:24:35,710 --> 01:24:40,289 of them later on in the course. But you can\n 901 01:24:40,289 --> 01:24:45,470 in here is that the string is a class, but\n 902 01:24:45,470 --> 01:24:50,259 one more kind of variables that I'm going\n 903 01:24:50,260 --> 01:24:57,539 Let's see that as well. We can say Boolean,\n 904 01:24:57,539 --> 01:25:04,269 you're using a Boolean, that Boolean can have\n 905 01:25:04,270 --> 01:25:10,250 two values that a Boolean can have. Once again,\n 906 01:25:10,250 --> 01:25:15,210 pass my Boolean in here. And let's run our\n 907 01:25:15,210 --> 01:25:21,590 printed. As I said, Our Boolean can have false\n 908 01:25:21,590 --> 01:25:26,960 False has been printed Boolean is very helpful\n 909 01:25:26,960 --> 01:25:31,399 We will talk about conditional statements\n 910 01:25:31,399 --> 01:25:36,129 about different variables in Java, there are\n 911 01:25:36,130 --> 01:25:41,211 out the Oracle documentation, but probably\n 912 01:25:41,211 --> 01:25:46,130 are all that we are going to use in this course.\n 913 01:25:46,130 --> 01:25:50,789 let's quickly talk about arithmetic operators\n 914 01:25:50,789 --> 01:25:56,310 all of these lines of code, because these\n 915 01:25:56,310 --> 01:26:00,870 these lines of code and not deleting them\n 916 01:26:00,869 --> 01:26:05,550 so that if you need, you can check the source\n 917 01:26:05,550 --> 01:26:11,930 quickly define two new integers, I can say\n 918 01:26:11,930 --> 01:26:18,740 int b is equal to let's say two. You can use\n 919 01:26:18,739 --> 01:26:24,059 kind of operation on your variable. We have\n 920 01:26:24,060 --> 01:26:28,770 that we're going to talk about in here is\n 921 01:26:28,770 --> 01:26:38,160 see them. For example, here I can say, answer\n 922 01:26:38,159 --> 01:26:42,930 arithmetic operator that we are going to talk\n 923 01:26:44,890 --> 01:26:50,789 let's quickly print our answer. And let's\n 924 01:26:50,789 --> 01:26:56,789 answer is eight, it has added B to A. The\n 925 01:26:56,789 --> 01:27:02,060 going to talk about in here is minus which\n 926 01:27:02,060 --> 01:27:07,530 B from a, the answer in here should be four,\n 927 01:27:07,529 --> 01:27:13,939 other one is the star, which is used for multiplying\n 928 01:27:13,939 --> 01:27:19,150 should be six times two, which is going to\n 929 01:27:19,150 --> 01:27:24,960 can see 12 in here, the other one is slash,\n 930 01:27:24,960 --> 01:27:31,090 divide six by two, let's run the application,\n 931 01:27:31,090 --> 01:27:35,890 that you need to be extra careful with this\n 932 01:27:35,890 --> 01:27:41,869 number V in this case should never be zero.\n 933 01:27:41,869 --> 01:27:46,859 And let's see what will be the result. Let's\n 934 01:27:46,859 --> 01:27:51,869 getting a read error in here we are getting\n 935 01:27:51,869 --> 01:27:57,359 exceptions later on in the course. But for\n 936 01:27:57,359 --> 01:28:02,060 our application crashes. Certainly we don't\n 937 01:28:02,060 --> 01:28:08,099 be careful about the second number. Or alternatively,\n 938 01:28:08,100 --> 01:28:13,289 that might occur. We will talk about exceptions\n 939 01:28:13,289 --> 01:28:18,970 of arithmetic operator in Java, and that's\n 940 01:28:18,970 --> 01:28:25,020 It's the person so the remainder operator\n 941 01:28:25,020 --> 01:28:32,080 by b. In this case, if we divide six by two,\n 942 01:28:32,079 --> 01:28:37,350 zero. So right now if I run the application,\n 943 01:28:37,350 --> 01:28:43,450 been printed down in here. But if I change\n 944 01:28:43,449 --> 01:28:49,059 remainder of five divided by two is one. Let's\n 945 01:28:49,060 --> 01:28:54,310 printed from time to time this remainder operator\n 946 01:28:54,310 --> 01:28:59,890 that I need to talk about the slash operator\n 947 01:28:59,890 --> 01:29:05,690 that if we divide five by two, we should see\n 948 01:29:05,689 --> 01:29:11,759 we can see that we can see that we are getting\n 949 01:29:11,760 --> 01:29:16,440 saved the answer inside an integer. If you\n 950 01:29:16,439 --> 01:29:21,619 said that integers can only contain whole\n 951 01:29:21,619 --> 01:29:27,609 numbers, you can use something like double.\n 952 01:29:27,609 --> 01:29:32,819 because the answer itself is an integer. If\n 953 01:29:32,819 --> 01:29:38,859 that a divided by b is an integer. If you\n 954 01:29:38,859 --> 01:29:44,630 the equal sign, you can open and close parentheses\n 955 01:29:44,630 --> 01:29:50,670 this way you have cast an integer to a double.\n 956 01:29:50,670 --> 01:29:57,131 that we are seeing 2.5 so if you want to see\n 957 01:29:57,131 --> 01:30:02,280 just talk a bit more about the plus operator.\n 958 01:30:02,279 --> 01:30:08,069 now if I use plus in here, you can guess the\n 959 01:30:08,069 --> 01:30:13,899 the application. We can see seven down in\n 960 01:30:13,899 --> 01:30:20,750 texts. For example, if I have to text in here,\n 961 01:30:20,750 --> 01:30:29,319 say, Emma. Let's also define another text.\n 962 01:30:29,319 --> 01:30:34,849 can use the plus operator to add these two\n 963 01:30:34,850 --> 01:30:43,060 Full Name is the call to first name, plus\n 964 01:30:43,060 --> 01:30:48,350 you can guess what would be the result. In\n 965 01:30:48,350 --> 01:30:53,960 a spacing here in order to see everything\n 966 01:30:53,960 --> 01:30:59,550 in here is called concatenating in Java, adding\n 967 01:30:59,550 --> 01:31:05,779 plus operator have two usages, it can be used\n 968 01:31:05,779 --> 01:31:15,199 we use it with different numbers, it will\n 969 01:31:15,199 --> 01:31:21,279 to talk about more operators in Java. Specifically,\n 970 01:31:21,279 --> 01:31:25,960 operators. Before doing that, let's quickly\n 971 01:31:25,960 --> 01:31:32,220 project by selecting Java and clicking on\n 972 01:31:32,220 --> 01:31:39,699 project. Let's name this project operators.\n 973 01:31:39,699 --> 01:31:46,340 folder, let's create our package. Let's say\n 974 01:31:46,340 --> 01:31:52,760 code dot operators. Inside our package, let's\n 975 01:31:52,760 --> 01:31:59,590 main. Inside our main class, we are going\n 976 01:31:59,590 --> 01:32:05,440 By pressing tab, we have our main method.\n 977 01:32:05,439 --> 01:32:09,939 operators. Let's quickly talk a bit more about\n 978 01:32:09,939 --> 01:32:15,569 the previous video, when we have to find a\n 979 01:32:15,569 --> 01:32:20,549 a value to that we could have say something\n 980 01:32:20,550 --> 01:32:28,420 is equal to a plus two. Or instead of defining\n 981 01:32:28,420 --> 01:32:34,649 plus two, it means that increase the value\n 982 01:32:34,649 --> 01:32:40,469 be its result. Let's run our application because\n 983 01:32:40,470 --> 01:32:46,699 dot Hello, you can see that the value of a\n 984 01:32:46,699 --> 01:32:52,550 we can say something like this, I'm going\n 985 01:32:52,550 --> 01:33:00,300 plus equal to let's also add some spaces,\n 986 01:33:00,300 --> 01:33:05,570 you can use plus equal in order to simplify\n 987 01:33:05,569 --> 01:33:12,439 again, you can see that the result is the\n 988 01:33:12,439 --> 01:33:18,049 for example, if you want to say a is equal\n 989 01:33:18,050 --> 01:33:25,360 we can say a plus equal one. Or alternatively,\n 990 01:33:25,359 --> 01:33:31,469 well, this a plus plus is going to increase\n 991 01:33:31,470 --> 01:33:38,110 we should see six as the value of a you can\n 992 01:33:38,110 --> 01:33:44,640 use minus as well, we can say a minus minus\n 993 01:33:44,640 --> 01:33:50,030 you're on our application, we can see four\n 994 01:33:50,029 --> 01:33:55,710 a minus equal to let's say two. For example.\n 995 01:33:55,710 --> 01:34:02,850 should see three as the value of a like minus\n 996 01:34:02,850 --> 01:34:08,820 also divided by equal it means that divide\n 997 01:34:08,819 --> 01:34:13,979 answer inside a this sentence in here is the\n 998 01:34:13,979 --> 01:34:20,219 I'm going to write we can say a is equal to\n 999 01:34:20,220 --> 01:34:24,920 the same. If you want to make sure of that\n 1000 01:34:24,920 --> 01:34:30,899 application. five divided by two is 2.5. Because\n 1001 01:34:30,899 --> 01:34:36,199 answer should be two. So we should see two\n 1002 01:34:36,199 --> 01:34:40,989 down in here. Before talking about logical\n 1003 01:34:40,989 --> 01:34:46,670 talk about these simplifications. Okay, now\n 1004 01:34:46,670 --> 01:34:52,480 comparison operators in Java comparison operators\n 1005 01:34:52,479 --> 01:34:57,289 things. For example, two numbers. Before that,\n 1006 01:34:57,289 --> 01:35:03,680 to say int a is equal to five After that,\n 1007 01:35:03,680 --> 01:35:10,690 After that we can say Boolean answer is equal\n 1008 01:35:10,689 --> 01:35:15,479 going to talk about in here is greater than\n 1009 01:35:15,479 --> 01:35:21,869 this, we can say, a greater than B, I have\n 1010 01:35:21,869 --> 01:35:27,349 a Boolean, this left anchor bracket in here\n 1011 01:35:27,350 --> 01:35:33,370 if a is greater than B, assigned the value\n 1012 01:35:33,369 --> 01:35:39,210 our answer we should see through, let's quickly\n 1013 01:35:39,210 --> 01:35:45,670 application, you can see that answer is true,\n 1014 01:35:45,670 --> 01:35:51,069 three, the other kind of comparison operator\n 1015 01:35:51,069 --> 01:35:56,479 bracket, right now, a is not less than b,\n 1016 01:35:56,479 --> 01:36:02,069 application, we should see false in the console.\n 1017 01:36:02,069 --> 01:36:06,569 operator that I'm going to talk about in here\n 1018 01:36:06,569 --> 01:36:13,029 equality between two integers. And that operator\n 1019 01:36:13,029 --> 01:36:18,380 not equal to b. So if we run our application,\n 1020 01:36:18,380 --> 01:36:24,220 run our application. And here we can see false.\n 1021 01:36:24,220 --> 01:36:29,060 signs, it means that we are checking for the\n 1022 01:36:29,060 --> 01:36:36,130 a single equal sign like in here and above,\n 1023 01:36:36,130 --> 01:36:41,000 Let's change the value of b to five. To see\n 1024 01:36:41,000 --> 01:36:46,760 let's run the application. Now you can see\n 1025 01:36:46,760 --> 01:36:53,289 of comparison operators as well. One of them\n 1026 01:36:53,289 --> 01:36:59,159 anchor bracket. And also this equal sign,\n 1027 01:36:59,159 --> 01:37:05,449 or if a is equal to b, right now, a is equal\n 1028 01:37:05,449 --> 01:37:10,659 run our application we should see through,\n 1029 01:37:10,659 --> 01:37:15,849 if A is five, and B would be something like\n 1030 01:37:15,850 --> 01:37:20,300 see through once again, we can see through.\n 1031 01:37:20,300 --> 01:37:25,659 to something like two, because none of these\n 1032 01:37:25,659 --> 01:37:31,670 false, let's run our application. And we can\n 1033 01:37:31,670 --> 01:37:37,710 less than equal. And we use that like this,\n 1034 01:37:37,710 --> 01:37:45,109 sign this in here means that check if a is\n 1035 01:37:45,109 --> 01:37:49,649 now, a is less than b. So the answer should\n 1036 01:37:49,649 --> 01:37:55,639 see through. But if we change the value of\n 1037 01:37:55,640 --> 01:38:01,800 And we can see false. Beside these, we also\n 1038 01:38:01,800 --> 01:38:07,289 And that's this explanation Mark plus the\n 1039 01:38:07,289 --> 01:38:13,119 A is not equal to b, this exclamation mark\n 1040 01:38:13,119 --> 01:38:19,109 operator right now, a is not equal to b. So\n 1041 01:38:19,109 --> 01:38:24,439 we should see through and through has been\n 1042 01:38:24,439 --> 01:38:28,579 operators that I was going to talk about,\n 1043 01:38:28,579 --> 01:38:33,670 going to use them a lot in our course. Next\n 1044 01:38:33,670 --> 01:38:38,600 in Java. But before that, let's quickly comment\n 1045 01:38:38,600 --> 01:38:44,630 define a new Boolean, let's say Boolean answer\n 1046 01:38:44,630 --> 01:38:52,630 will talk about it, we can say a is equal\n 1047 01:38:52,630 --> 01:38:58,720 like two. This is our first logical operator\n 1048 01:38:58,720 --> 01:39:06,199 pipelines by using shift plus backslash backslash\n 1049 01:39:06,199 --> 01:39:13,139 So in here, this OR operator means that if\n 1050 01:39:13,140 --> 01:39:18,260 assign through to this answer, if none of\n 1051 01:39:18,260 --> 01:39:24,409 to this answer, right now, a is equal to five\n 1052 01:39:24,409 --> 01:39:29,649 the answer should be true. So if we print\n 1053 01:39:29,649 --> 01:39:35,259 the application. And you can see through down\n 1054 01:39:35,260 --> 01:39:42,430 to six, because none of these conditions are\n 1055 01:39:42,430 --> 01:39:46,539 And then here we can see false. The other\n 1056 01:39:46,539 --> 01:39:52,600 talk about is to add science. Let's quickly\n 1057 01:39:52,600 --> 01:39:58,390 it means that assign through to answer if\n 1058 01:39:58,390 --> 01:40:04,680 equal to five and also if B is equal to two\n 1059 01:40:04,680 --> 01:40:09,100 assign false the answer right now, none of\n 1060 01:40:09,100 --> 01:40:14,800 false as our answer. Let's run the application.\n 1061 01:40:14,800 --> 01:40:20,829 change the value of a to five, and run our\n 1062 01:40:20,829 --> 01:40:25,949 because the second condition is not true.\n 1063 01:40:25,949 --> 01:40:30,929 our application, this time we should see through\n 1064 01:40:30,930 --> 01:40:36,180 were the two kinds of logical operators that\n 1065 01:40:36,180 --> 01:40:41,570 we have talked about operators that we wanted,\n 1066 01:40:41,569 --> 01:40:45,609 going to comment these two lines of code.\n 1067 01:40:45,609 --> 01:40:50,559 I'm going to talk about is called if statements,\n 1068 01:40:50,560 --> 01:40:56,730 if a pair of parentheses inside the parentheses\n 1069 01:40:56,729 --> 01:41:03,509 we can say if a is greater than three, after\n 1070 01:41:03,510 --> 01:41:10,880 inside the curly braces, we can put our code\n 1071 01:41:10,880 --> 01:41:16,300 So in here, we are saying that if our condition\n 1072 01:41:16,300 --> 01:41:22,650 braces. If it's not true, jump to after the\n 1073 01:41:22,649 --> 01:41:28,799 say continue. Right now a is five, and it's\n 1074 01:41:28,800 --> 01:41:34,510 text printed, let's run our application, you\n 1075 01:41:34,510 --> 01:41:37,480 if we change the value of a to something like\ntwo 1076 01:41:37,479 --> 01:41:43,569 and run our application, you can see that\n 1077 01:41:43,569 --> 01:41:50,479 we can also have multiple conditions. For\n 1078 01:41:50,479 --> 01:41:55,319 another pair of curly braces inside these\n 1079 01:41:55,319 --> 01:42:02,509 I can say a is less than three. Right now\n 1080 01:42:02,510 --> 01:42:09,090 see only this text printed, let's run our\n 1081 01:42:09,090 --> 01:42:14,480 three. As for the condition, you can provide\n 1082 01:42:14,479 --> 01:42:20,039 if statement parentheses or you can define\n 1083 01:42:20,039 --> 01:42:27,649 example, in here, if I say Boolean answer\n 1084 01:42:27,649 --> 01:42:34,079 pass my answer. inside these parentheses,\n 1085 01:42:34,079 --> 01:42:38,729 minimize this ramping for now. This is going\n 1086 01:42:38,729 --> 01:42:45,169 highlighting here, the intelligent ID is warning\n 1087 01:42:45,170 --> 01:42:50,690 equals equals to true can be simplified to\n 1088 01:42:50,689 --> 01:42:54,889 this is going to work exactly the same. If\n 1089 01:42:54,890 --> 01:43:00,940 same result a is less than three. Let's run\n 1090 01:43:00,939 --> 01:43:06,379 than three. If we want to negate this answer,\n 1091 01:43:06,380 --> 01:43:11,489 variable. For example, in here we can say\n 1092 01:43:11,489 --> 01:43:16,710 our application, we should see the first line,\n 1093 01:43:16,710 --> 01:43:22,779 is not true because A is true. But in here\n 1094 01:43:22,779 --> 01:43:27,069 we have added a negative meaning. Let's delete\n 1095 01:43:27,069 --> 01:43:33,000 once again. Besides else, you can also have\n 1096 01:43:33,000 --> 01:43:38,510 this if statement. And let's write another\n 1097 01:43:38,510 --> 01:43:44,720 this if statement. Let's check that if a is\n 1098 01:43:44,720 --> 01:43:51,610 than zero, inside the curly braces, let's\n 1099 01:43:51,609 --> 01:43:57,130 I can use something like this, I can say else\n 1100 01:43:57,130 --> 01:44:04,650 here we can say if a is less than zero. Once\n 1101 01:44:04,649 --> 01:44:12,569 the curly braces, we can say a is negative.\n 1102 01:44:12,569 --> 01:44:17,609 For example, I can add another one in here.\n 1103 01:44:17,609 --> 01:44:23,489 if statement would mean anything. But you\n 1104 01:44:23,489 --> 01:44:30,219 if statement you can have at most one else\n 1105 01:44:30,220 --> 01:44:35,510 I can have only one l space this else is going\n 1106 01:44:35,510 --> 01:44:42,440 use this else, it means that a is not greater\n 1107 01:44:42,439 --> 01:44:48,969 So it is zero. In here we can safely say a\n 1108 01:44:48,970 --> 01:44:54,869 for our if statement right now A is true.\n 1109 01:44:54,869 --> 01:45:02,550 our application. And as you can see a is positive.\n 1110 01:45:02,550 --> 01:45:07,360 application, you can guess it, we should see\n 1111 01:45:07,359 --> 01:45:14,359 here. If we change the value of oil to zero,\n 1112 01:45:14,359 --> 01:45:20,079 we can see that down in here. So if statements\n 1113 01:45:20,079 --> 01:45:25,760 have another one as well, let's comment all\n 1114 01:45:25,760 --> 01:45:31,090 Let's see that as well, we can say switch\n 1115 01:45:31,090 --> 01:45:36,170 we need to provide the variable that we want\n 1116 01:45:36,170 --> 01:45:43,430 here, after the parentheses, I can provide\n 1117 01:45:43,430 --> 01:45:48,920 I can define different cases. For example,\n 1118 01:45:48,920 --> 01:45:55,060 that we need a column. And in case a is one,\n 1119 01:45:55,060 --> 01:46:02,190 see a is one. Also, it's very important to\n 1120 01:46:02,189 --> 01:46:07,539 that. I will talk about this break in a minute.\n 1121 01:46:07,539 --> 01:46:12,840 you are going to need a break, we can define\n 1122 01:46:12,840 --> 01:46:20,949 I can say in case a is to screen something,\n 1123 01:46:20,949 --> 01:46:29,439 we can define another case. For example, for\n 1124 01:46:29,439 --> 01:46:34,609 statement, we are going to need a default\n 1125 01:46:34,609 --> 01:46:42,049 we can say default. And we can print something\n 1126 01:46:42,050 --> 01:46:48,350 case, we need the break as well. Let's quickly\n 1127 01:46:48,350 --> 01:46:55,030 Let's change that to two. And you can guess\n 1128 01:46:55,029 --> 01:47:00,659 And you can see a is two, if we change the\n 1129 01:47:00,659 --> 01:47:06,880 application. You can see a is not one, two\n 1130 01:47:06,880 --> 01:47:12,859 in here. But before that, let's quickly change\n 1131 01:47:12,859 --> 01:47:17,939 will cause our switch statement to break.\n 1132 01:47:17,939 --> 01:47:23,799 here at the first days, which is a is equal\n 1133 01:47:23,800 --> 01:47:29,100 you can see that even though a is one we can\n 1134 01:47:29,100 --> 01:47:34,750 a is two in here. Because we don't have any\n 1135 01:47:34,750 --> 01:47:40,149 And we have jumped to the second statement.\n 1136 01:47:40,149 --> 01:47:49,199 case in your switch statement. We are going\n 1137 01:47:49,199 --> 01:47:54,880 let me just say that I have created my project,\n 1138 01:47:54,880 --> 01:48:00,920 folder. Inside this package we have only one\n 1139 01:48:00,920 --> 01:48:05,940 I hope that you can come to this point by\n 1140 01:48:05,939 --> 01:48:12,519 videos on how to create a project and create\n 1141 01:48:12,520 --> 01:48:17,820 loops are useful for when you want to do a\n 1142 01:48:17,819 --> 01:48:24,059 print something 10 times like this in here.\n 1143 01:48:24,060 --> 01:48:30,920 can just copy and paste it 10 times what in\n 1144 01:48:30,920 --> 01:48:35,170 paste yourself whenever in programming you're\n 1145 01:48:35,170 --> 01:48:41,159 something wrong. Instead of copy and pasting\n 1146 01:48:41,159 --> 01:48:46,420 first kind of loops that I'm going to talk\n 1147 01:48:46,420 --> 01:48:53,000 will talk about its syntax. This is the general\n 1148 01:48:53,000 --> 01:48:59,640 for. After that we have a pair of parentheses\n 1149 01:48:59,640 --> 01:49:05,020 in the first statement we are defining a new\n 1150 01:49:05,020 --> 01:49:11,550 whatever you want, and also we are initializing\n 1151 01:49:11,550 --> 01:49:17,190 statement is the condition of our for loop\n 1152 01:49:17,189 --> 01:49:23,399 condition is not met. And the third statement\n 1153 01:49:23,399 --> 01:49:29,589 of i every time that we look PVC inaction\n 1154 01:49:29,590 --> 01:49:35,659 we have a pair of curly braces in which we\n 1155 01:49:35,659 --> 01:49:41,630 if we want to print something like hello here,\n 1156 01:49:41,630 --> 01:49:46,579 braces. So what this for loop is going to\n 1157 01:49:46,579 --> 01:49:52,460 new integer called AI and we are assigning\n 1158 01:49:52,460 --> 01:49:57,840 we are checking our condition we are checking\n 1159 01:49:57,840 --> 01:50:03,909 that we are going to look i is Hello So this\n 1160 01:50:03,909 --> 01:50:08,550 we are going to execute the code inside the\n 1161 01:50:08,550 --> 01:50:13,579 print hello. After printing Hello, we are\n 1162 01:50:13,579 --> 01:50:18,920 case, we are going to increase the value of\n 1163 01:50:18,920 --> 01:50:23,940 to loop first of all we are going to check\n 1164 01:50:23,939 --> 01:50:30,509 still less than 10 or not. For the second\n 1165 01:50:30,510 --> 01:50:36,050 we are going to execute our code. This circling\n 1166 01:50:36,050 --> 01:50:41,829 our condition is false. When it's false, we\n 1167 01:50:41,829 --> 01:50:46,819 this case, we are going to print hello 10\n 1168 01:50:46,819 --> 01:50:52,779 see if we can see Hello 10 times, you can\n 1169 01:50:52,779 --> 01:50:58,119 seems to be perfect. Instead of 10. You can\n 1170 01:50:58,119 --> 01:51:03,250 example, you can say five, if you execute\n 1171 01:51:03,250 --> 01:51:09,020 be printed five times, instead of this five\n 1172 01:51:09,020 --> 01:51:14,850 if you had a variable before this for loop,\n 1173 01:51:14,850 --> 01:51:20,390 later on, we can pass a instead of five to\n 1174 01:51:20,390 --> 01:51:26,100 five, we can say if you run the application,\n 1175 01:51:26,100 --> 01:51:32,280 for loop we can also have access to the eye\n 1176 01:51:32,279 --> 01:51:38,989 we can print by, let's quickly paint that\n 1177 01:51:38,989 --> 01:51:44,590 can see that we are printing the numbers zero\n 1178 01:51:44,590 --> 01:51:49,779 in Java. The other point is my loop. Let's\n 1179 01:51:49,779 --> 01:51:58,859 going to write the syntax of while loop and\n 1180 01:51:58,859 --> 01:52:03,609 This is the general syntax of a wild loop.\n 1181 01:52:03,609 --> 01:52:09,609 have a pair of parentheses inside the parentheses\n 1182 01:52:09,609 --> 01:52:15,549 than 10. After that we have a pair of curly\n 1183 01:52:15,550 --> 01:52:20,710 our code. In this case we are going to print\n 1184 01:52:20,710 --> 01:52:25,880 value of a so this condition is always true.\n 1185 01:52:25,880 --> 01:52:31,590 are going to stuck in an infinite loop. Let\n 1186 01:52:31,590 --> 01:52:37,529 an infinite loop looks like. But before that,\n 1187 01:52:37,529 --> 01:52:43,149 that no matter what happens, we are inside\n 1188 01:52:43,149 --> 01:52:49,599 In some cases, this might be our desired behavior.\n 1189 01:52:49,600 --> 01:52:55,910 that we can exit our application by pressing\n 1190 01:52:55,909 --> 01:53:00,939 exit code which is negative one in a normal\n 1191 01:53:00,939 --> 01:53:07,099 how can we exit a wild? There are multiple\n 1192 01:53:07,100 --> 01:53:14,350 the value of a inside the void loop. For example,\n 1193 01:53:14,350 --> 01:53:20,410 in order to increase the value of a so that\n 1194 01:53:20,409 --> 01:53:26,289 going to loop through this while loop. So\n 1195 01:53:26,289 --> 01:53:30,840 so our condition is true. So we are going\n 1196 01:53:30,840 --> 01:53:36,460 going to loop through the cycle until a is\n 1197 01:53:36,460 --> 01:53:41,470 no longer met. And we are going to break out\n 1198 01:53:41,470 --> 01:53:47,720 one more time. This time you can see that\n 1199 01:53:47,720 --> 01:53:53,250 also this exit code is zero which means that\n 1200 01:53:53,250 --> 01:53:59,659 without any error. The other way that break\n 1201 01:53:59,659 --> 01:54:06,149 quickly add that this time after the first\n 1202 01:54:06,149 --> 01:54:12,029 loop it means that we are going to print hello\n 1203 01:54:12,029 --> 01:54:17,939 in here you can see that we have printed Hello\n 1204 01:54:17,939 --> 01:54:23,339 keyword called continue. Let's quickly see\n 1205 01:54:23,340 --> 01:54:28,710 and before this print statement, I'm going\n 1206 01:54:28,710 --> 01:54:36,500 equal to eight. Then let's continue. This\n 1207 01:54:36,500 --> 01:54:41,920 record of your while loop go to the next round\n 1208 01:54:41,920 --> 01:54:47,399 the rest of the code inside the viable break\n 1209 01:54:47,399 --> 01:54:53,839 so for example in this case, if A is five,\n 1210 01:54:53,840 --> 01:54:59,010 But if a is eight you're not going to print\n 1211 01:54:59,010 --> 01:55:04,579 in case if a is nice. If you don't want to\n 1212 01:55:04,579 --> 01:55:10,300 change the value of a software inside the\n 1213 01:55:10,300 --> 01:55:16,010 I can say a plus was right now if I run my\n 1214 01:55:16,010 --> 01:55:21,100 times, because if a is eight, we are going\n 1215 01:55:21,100 --> 01:55:26,150 going to jump to the next record and we are\n 1216 01:55:26,149 --> 01:55:31,639 and see if we can see Hello four times. And\n 1217 01:55:31,640 --> 01:55:37,670 So continue is a useful keyword for when you\n 1218 01:55:37,670 --> 01:55:43,190 that we have talked about why loop let's also\n 1219 01:55:43,189 --> 01:55:50,549 the value of A in here is five. If we change\n 1220 01:55:50,550 --> 01:55:56,350 we know that this condition is no longer true.\n 1221 01:55:56,350 --> 01:56:01,980 it means that we are not going to run the\n 1222 01:56:01,979 --> 01:56:06,859 we shouldn't see any Hello printed into our\n 1223 01:56:06,859 --> 01:56:12,460 any Hello. But in some cases, you may want\n 1224 01:56:12,460 --> 01:56:18,381 no matter what the condition is. For those\n 1225 01:56:18,381 --> 01:56:24,350 me comment this while loop and let's create\n 1226 01:56:24,350 --> 01:56:30,300 you need to type do inside the curly braces,\n 1227 01:56:30,300 --> 01:56:36,489 can say System dot out dot print line. And\n 1228 01:56:36,489 --> 01:56:42,149 we need to say why. And inside the parentheses\n 1229 01:56:42,149 --> 01:56:48,769 we need to say a less than five, after the\n 1230 01:56:48,770 --> 01:56:53,940 in this case, because A is equal to five,\n 1231 01:56:53,939 --> 01:56:59,269 with that condition, we should see this Hello\n 1232 01:56:59,270 --> 01:57:04,490 loops. Let's run the application. And let's\n 1233 01:57:04,489 --> 01:57:10,199 can see Hello only once. So do while loops\n 1234 01:57:10,199 --> 01:57:15,359 code, at least one no matter what the condition\n 1235 01:57:15,359 --> 01:57:21,029 Java called for each loops. But I'm not going\n 1236 01:57:21,029 --> 01:57:26,259 that if we know about different arrays and\n 1237 01:57:26,260 --> 01:57:32,030 about object oriented programming, we will\n 1238 01:57:32,029 --> 01:57:37,149 talk about for each loops after we have learned\n 1239 01:57:37,149 --> 01:57:42,469 enough for loops. Now we are going to have\n 1240 01:57:42,470 --> 01:57:46,471 challenge, we need to know about two more\n 1241 01:57:46,470 --> 01:57:52,339 input. And also we need to know how to generate\n 1242 01:57:52,340 --> 01:57:57,510 how these two are going to be useful. In order\n 1243 01:57:57,510 --> 01:58:02,650 called a scanner. The syntax in here might\n 1244 01:58:02,649 --> 01:58:07,859 talked about object oriented programming.\n 1245 01:58:07,859 --> 01:58:12,659 Because we want to have an interactive challenge.\n 1246 01:58:12,659 --> 01:58:17,090 and paste the code that I'm writing in here.\n 1247 01:58:17,090 --> 01:58:21,840 something like this, you can see the scanner\n 1248 01:58:21,840 --> 01:58:27,150 Java dot util package. After that, you need\n 1249 01:58:27,149 --> 01:58:33,549 a scanner, after that you can say is equal\n 1250 01:58:33,550 --> 01:58:39,550 inside the parentheses you need to say system.in\n 1251 01:58:39,550 --> 01:58:45,970 for outputting something system that is useful\n 1252 01:58:45,970 --> 01:58:53,590 Now you have a scanner, you can get a number\n 1253 01:58:53,590 --> 01:59:01,610 is equal to a scanner, dot next int this one\n 1254 01:59:01,609 --> 01:59:07,199 our scanner is going to wait for the user's\n 1255 01:59:07,199 --> 01:59:12,840 will see that in action in a minute. But before\n 1256 01:59:12,840 --> 01:59:20,319 example, let's say answer was plus the value\n 1257 01:59:20,319 --> 01:59:27,519 our scanner. Let's say please enter a number.\n 1258 01:59:27,520 --> 01:59:32,960 these few lines of code are going to do. You\n 1259 01:59:32,960 --> 01:59:39,520 number text. And in here console is waiting\n 1260 01:59:39,520 --> 01:59:46,140 I can say five by pressing Enter. You can\n 1261 01:59:46,140 --> 01:59:52,470 our application successfully. So by using\n 1262 01:59:52,470 --> 01:59:57,860 integers beside number, you can also get a\n 1263 01:59:57,859 --> 02:00:04,889 see that as well. First of all, let's go Something,\n 1264 02:00:04,890 --> 02:00:08,610 say something like this, I can say the string\nname 1265 02:00:08,609 --> 02:00:14,839 is equal to scanner dot next, you can see\n 1266 02:00:14,840 --> 02:00:20,380 string. Don't worry about all of these new\n 1267 02:00:20,380 --> 02:00:25,050 programming. We will talk about all of these\n 1268 02:00:25,050 --> 02:00:31,289 to need the user's input, we are going to\n 1269 02:00:31,289 --> 02:00:36,920 scanner dot, Next, you're going to get the\n 1270 02:00:36,920 --> 02:00:42,390 something. Let's say hello, close the name\n 1271 02:00:42,390 --> 02:00:48,650 again. In here, first of all, we need to enter\n 1272 02:00:48,649 --> 02:00:55,689 is waiting for my name, let's say Mesa. And\n 1273 02:00:55,689 --> 02:01:01,379 we can get the user's input. Let's also see\n 1274 02:01:01,380 --> 02:01:06,199 to comment these lines of code for now, in\n 1275 02:01:06,199 --> 02:01:11,979 say something like this, you can say random\n 1276 02:01:11,979 --> 02:01:18,029 to new random. And we don't need to provide\n 1277 02:01:18,029 --> 02:01:23,529 in order to generate a random number, we can\n 1278 02:01:23,529 --> 02:01:31,269 random dot next int, this method in here is\n 1279 02:01:31,270 --> 02:01:39,390 that number. That's the number plus the number.\n 1280 02:01:39,390 --> 02:01:45,480 can see that we have this random number. It's\n 1281 02:01:45,479 --> 02:01:52,069 number. Right now, our random number is this\n 1282 02:01:52,069 --> 02:01:57,039 it's good to define a domain. In order to\n 1283 02:01:57,039 --> 02:02:03,359 to this next int method. For example, if I\n 1284 02:02:03,359 --> 02:02:08,969 once again, the number should be somewhere\n 1285 02:02:08,970 --> 02:02:15,710 number to be somewhere between one to 20,\n 1286 02:02:15,710 --> 02:02:21,230 plus, but let's run the application. Once\n 1287 02:02:21,229 --> 02:02:26,059 here is completely random. It means that every\n 1288 02:02:26,060 --> 02:02:30,950 see a different number, you can see that we\n 1289 02:02:30,949 --> 02:02:36,529 that we know how to get a random number and\n 1290 02:02:36,529 --> 02:02:42,359 for our challenge. Here is our challenge we\n 1291 02:02:42,359 --> 02:02:48,460 this game is to generate a random number and\n 1292 02:02:48,460 --> 02:02:54,550 asking the user until you receive the correct\n 1293 02:02:54,550 --> 02:02:59,550 After five times of guessing gronke show a\n 1294 02:02:59,550 --> 02:03:04,770 our game is going to work. First of all, we\n 1295 02:03:04,770 --> 02:03:10,000 that we are going to ask for the user's name.\n 1296 02:03:10,000 --> 02:03:15,050 After that, we are going to ask for the user's\n 1297 02:03:15,050 --> 02:03:20,190 a positive answer, we are going to generate\n 1298 02:03:20,189 --> 02:03:25,460 the users guests. If the guest is correct,\n 1299 02:03:25,460 --> 02:03:31,329 and quit the game. If the guest is wrong,\n 1300 02:03:31,329 --> 02:03:36,680 the correct number. Also, as a hint to the\n 1301 02:03:36,680 --> 02:03:42,180 you're asking for a number tell the user to\n 1302 02:03:42,180 --> 02:03:47,800 random number is 10. If the user has guessed\n 1303 02:03:47,800 --> 02:03:54,270 higher if the user failed after five times,\n 1304 02:03:54,270 --> 02:03:58,980 This challenging here is the combination of\n 1305 02:03:58,979 --> 02:04:03,489 make sure to practice before watching the\n 1306 02:04:03,489 --> 02:04:08,849 Okay, go solve the challenge. And after that,\n 1307 02:04:08,850 --> 02:04:18,110 my solution for this challenge. See you in\n 1308 02:04:18,109 --> 02:04:24,489 but if not, that's totally okay. After all,\n 1309 02:04:24,489 --> 02:04:29,269 the first application that you're writing.\n 1310 02:04:29,270 --> 02:04:36,260 together. Let's start by creating a new project.\n 1311 02:04:36,260 --> 02:04:45,000 Once again next, let's name this project gets\n 1312 02:04:45,000 --> 02:04:50,970 our source folder, let's create our package\n 1313 02:04:51,970 --> 02:04:59,750 that gives me a new Java class. Let's name\n 1314 02:04:59,750 --> 02:05:06,300 p SVM and now we have our main method. Okay,\n 1315 02:05:06,300 --> 02:05:13,890 message to the user. So let's say System dot\n 1316 02:05:13,890 --> 02:05:20,240 After that, we are going to ask for the user's\n 1317 02:05:20,239 --> 02:05:26,300 or marry have your name. After that, we need\n 1318 02:05:26,300 --> 02:05:33,480 a scanner for that. Let's create our scanner.\n 1319 02:05:33,479 --> 02:05:41,669 system.me. After that, let's say string name\n 1320 02:05:41,670 --> 02:05:50,551 say hello to the user. Let's say hello, plus\n 1321 02:05:50,551 --> 02:05:58,720 permission to start the game. Let's say Shall\n 1322 02:05:58,720 --> 02:06:08,500 two option. And here are my two options. Let's\n 1323 02:06:08,500 --> 02:06:13,529 But in order to format my text a little bit\n 1324 02:06:13,529 --> 02:06:20,439 in here in which you haven't seen so far.\n 1325 02:06:20,439 --> 02:06:26,819 this. Yes. So this will be formatted with\n 1326 02:06:26,819 --> 02:06:32,149 is special Just for formatting my text a little\n 1327 02:06:32,149 --> 02:06:41,219 the user's answer. Let's say eight, begin\n 1328 02:06:41,220 --> 02:06:47,659 And after that, I'm going to create a while\n 1329 02:06:47,659 --> 02:06:54,630 to one, we are going to continue asking our\n 1330 02:06:54,630 --> 02:07:00,470 code and paste them inside our while loop.\n 1331 02:07:00,470 --> 02:07:06,740 to store the new users answer for that we\n 1332 02:07:06,739 --> 02:07:12,800 dot next int. This way, if you are not going\n 1333 02:07:12,800 --> 02:07:18,360 users answer is valid, when it's fun, we have\n 1334 02:07:18,359 --> 02:07:23,659 void loop, it's time to generate a random\n 1335 02:07:23,659 --> 02:07:31,840 to a new random. After death, let's say int\n 1336 02:07:31,840 --> 02:07:38,380 domain, I'm going to say 20. Because I want\n 1337 02:07:38,380 --> 02:07:44,400 to add a plus one in here. After that, it's\n 1338 02:07:46,130 --> 02:07:51,510 please get a number. And in here, we need\n 1339 02:07:51,510 --> 02:08:00,430 Let's say int, user input is equal to a scanner\n 1340 02:08:00,430 --> 02:08:06,560 three new variables and their usage as will\n 1341 02:08:06,560 --> 02:08:12,700 them. First of all, I'm going to save the\n 1342 02:08:12,699 --> 02:08:20,069 say eight times tried is equal to zero initially,\n 1343 02:08:20,069 --> 02:08:29,359 say Boolean. As well, initially, it's false.\n 1344 02:08:29,359 --> 02:08:35,279 should finish the game. So let's say should\n 1345 02:08:35,279 --> 02:08:39,829 Initially, After defining these three new\n 1346 02:08:39,829 --> 02:08:45,229 of let's say, why should finish is not equal\nto two. 1347 02:08:46,560 --> 02:08:52,170 inside the while loop, first of all, I'm going\n 1348 02:08:52,170 --> 02:08:58,319 So let's say times three plus plus, after\n 1349 02:08:58,319 --> 02:09:05,779 Let's say if times three is less than five,\n 1350 02:09:05,779 --> 02:09:11,760 it's more than five, in the else case, we\n 1351 02:09:11,761 --> 02:09:17,640 that, I'm just going to say short finish is\n 1352 02:09:17,640 --> 02:09:22,789 line of our while loop. So if we look once\n 1353 02:09:22,789 --> 02:09:27,689 met, we are going to break out of the while\n 1354 02:09:27,689 --> 02:09:33,599 than five, we are going to check that if the\n 1355 02:09:33,600 --> 02:09:41,590 number for that I can say if user input is\n 1356 02:09:41,590 --> 02:09:47,850 of husband to true because user has won the\n 1357 02:09:47,850 --> 02:09:53,610 while loop let's say short finish is equal\n 1358 02:09:53,609 --> 02:10:03,229 if statement. Let's say else. if let's say\n 1359 02:10:03,229 --> 02:10:09,009 is our randomly generated number, we are going\n 1360 02:10:09,010 --> 02:10:15,640 can say, guessed lower. And of course, we\n 1361 02:10:15,640 --> 02:10:22,230 that we can say user input is equal to a scanner\n 1362 02:10:22,229 --> 02:10:29,099 here in case the number is less than x. If\n 1363 02:10:29,100 --> 02:10:34,860 user to guess higher. And also if you're going\n 1364 02:10:34,859 --> 02:10:41,319 user input is equal to scanner dot next int.\n 1365 02:10:41,319 --> 02:10:46,409 what we are doing in here. But after the void\n 1366 02:10:46,409 --> 02:10:54,359 say if the user has won the game. If that's\n 1367 02:10:54,359 --> 02:11:00,550 let's say congratulation. And also let's say\n 1368 02:11:00,551 --> 02:11:12,039 the game. Let's say you have guessed in your\n 1369 02:11:12,039 --> 02:11:18,359 case, first level, we are going to show a\n 1370 02:11:18,359 --> 02:11:22,549 after that, we are going to say what was the\nnumber 1371 02:11:22,550 --> 02:11:30,279 let's say the number was plus x. This is our\n 1372 02:11:30,279 --> 02:11:35,840 doing in here. First of all, we are showing\n 1373 02:11:35,840 --> 02:11:41,510 we are asking for the user's name, we are\n 1374 02:11:41,510 --> 02:11:47,050 for the user to enter his or her name. After\n 1375 02:11:47,050 --> 02:11:53,050 user's permission to start the game, we are\n 1376 02:11:53,050 --> 02:11:58,079 while loop we are making sure that we have\n 1377 02:11:58,079 --> 02:12:03,350 we are going to ask again and again until\n 1378 02:12:03,350 --> 02:12:08,900 sure that we have the permission, we are creating\n 1379 02:12:08,899 --> 02:12:15,319 one to 20. And after that, we are asking the\n 1380 02:12:15,319 --> 02:12:21,170 user's input in here, we have defined three\n 1381 02:12:21,170 --> 02:12:27,350 one and short finish. Next, we are creating\n 1382 02:12:27,350 --> 02:12:33,070 in here. The condition of this viral loop\n 1383 02:12:33,069 --> 02:12:38,920 the loop. First thing inside this while loop\n 1384 02:12:38,920 --> 02:12:44,859 the first time because the time stride is\n 1385 02:12:44,859 --> 02:12:50,210 After that we are checking that if times three\n 1386 02:12:50,210 --> 02:12:56,069 input with the randomly generated number.\n 1387 02:12:56,069 --> 02:13:01,149 changing the value of this husband to true\n 1388 02:13:01,149 --> 02:13:05,979 So we are changing the value of this short\n 1389 02:13:05,979 --> 02:13:11,159 is greater than our random number, we are\n 1390 02:13:11,159 --> 02:13:17,779 are waiting for the user's input. But in case\n 1391 02:13:17,779 --> 02:13:23,389 we are telling the user to guess higher once\n 1392 02:13:23,390 --> 02:13:29,350 in case the time strike is greater than five,\n 1393 02:13:29,350 --> 02:13:35,530 the case, the husband is still false. So we\n 1394 02:13:35,529 --> 02:13:41,789 to true it means that user has won the game.\n 1395 02:13:41,789 --> 02:13:47,269 Also we are showing that English try the user\n 1396 02:13:47,270 --> 02:13:52,710 if the user didn't want the game, we are showing\n 1397 02:13:52,710 --> 02:13:58,730 the random number. Let's run the game and\n 1398 02:13:58,729 --> 02:14:05,529 seeing the welcome message. After that it's\n 1399 02:14:05,529 --> 02:14:11,229 seeing Hello Mesa after that we are seeing\n 1400 02:14:11,229 --> 02:14:17,299 or it was better to say Shall we begin? Let's\n 1401 02:14:17,300 --> 02:14:22,650 message. This is our first wide look. Also\n 1402 02:14:22,649 --> 02:14:28,629 t that I have used when I have created this\n 1403 02:14:28,630 --> 02:14:33,859 t in here. Also beside one and two. If you\n 1404 02:14:33,859 --> 02:14:37,939 message once again. So let's say three for\n 1405 02:14:37,939 --> 02:14:44,259 message. Okay, let's say Yes to continue.\n 1406 02:14:44,260 --> 02:14:50,470 Let's say 10 it says gets lower, let's say\n 1407 02:14:50,470 --> 02:14:58,360 my second Troy. Okay, let's run the game once\n 1408 02:14:58,359 --> 02:15:04,899 Yes. Let's begin. That's guess another number.\n 1409 02:15:04,899 --> 02:15:14,789 higher in order to debug all the features\n 1410 02:15:14,789 --> 02:15:21,250 see that after five Troy, I can see the gameover\n 1411 02:15:21,250 --> 02:15:26,710 nine. Okay, it seems like our application\n 1412 02:15:26,710 --> 02:15:34,079 this video, let's change this message in here\n 1413 02:15:34,079 --> 02:15:40,319 Okay, this was our challenge. I hope you solved\n 1414 02:15:40,319 --> 02:15:45,559 okay. Later on in the course, we are going\n 1415 02:15:45,560 --> 02:15:50,550 that we make sure that we have learned everything\n 1416 02:15:50,550 --> 02:15:54,720 a good point to stop the video in here. Just\n 1417 02:15:54,720 --> 02:15:58,610 the next video, we are going to talk about\narrays in Java. 1418 02:15:58,609 --> 02:16:07,769 See you in the next video. In this video,\n 1419 02:16:07,770 --> 02:16:13,460 Up until now if we wanted to store some simple\n 1420 02:16:13,460 --> 02:16:20,180 we could have used variables. For example,\n 1421 02:16:20,180 --> 02:16:25,240 But what if we want to store a list of different\n 1422 02:16:25,239 --> 02:16:31,630 a list of students. for storing a list of\n 1423 02:16:31,630 --> 02:16:36,308 The first one that we are going to talk about\n 1424 02:16:36,308 --> 02:16:42,058 we can have an array of for example strings.\n 1425 02:16:42,058 --> 02:16:47,170 we need a pair of square brackets. After that,\n 1426 02:16:47,170 --> 02:16:53,780 I can say students, next I can say new string\n 1427 02:16:53,780 --> 02:16:59,340 This new keyboard in here is simple English,\n 1428 02:16:59,340 --> 02:17:05,010 of strings inside this square bracket, we\n 1429 02:17:05,010 --> 02:17:09,840 if we want to serve five different student\n 1430 02:17:09,840 --> 02:17:15,940 that now we have an array of size five. After\n 1431 02:17:15,940 --> 02:17:24,090 into it. For example, I can say the students\n 1432 02:17:24,090 --> 02:17:29,719 to let's put my name in here It may sound\n 1433 02:17:29,718 --> 02:17:34,989 element in which has the index of one in our\n 1434 02:17:34,989 --> 02:17:40,959 here and that indexes in Java starts from\n 1435 02:17:40,959 --> 02:17:46,339 with an index of one, it means that we are\n 1436 02:17:46,340 --> 02:17:51,049 If you want to assign some value to your first\n 1437 02:17:51,049 --> 02:17:59,049 with an index of zero. Let's see that as well,\n 1438 02:17:59,049 --> 02:18:05,000 can keep doing this for all of our elements\n 1439 02:18:05,000 --> 02:18:10,399 to your array elements, you can also get the\n 1440 02:18:10,399 --> 02:18:14,779 in here, we can say print the value of a student\n 1441 02:18:16,260 --> 02:18:20,700 guess it in this case, it should be Tom. Let's\n 1442 02:18:20,700 --> 02:18:26,679 Tom. As you can see, Tom has been printed.\n 1443 02:18:26,679 --> 02:18:31,809 to your array elements. The other way is like\n 1444 02:18:31,809 --> 02:18:37,049 time of creating your area. For example, in\n 1445 02:18:37,049 --> 02:18:43,759 it employees is equal to instead of saying\n 1446 02:18:43,760 --> 02:18:50,610 brace. And inside that curly brace, I can\n 1447 02:18:50,610 --> 02:18:56,360 or every other value that I want. So these\n 1448 02:18:56,360 --> 02:19:01,560 array elements, like a string array, you can\n 1449 02:19:01,559 --> 02:19:06,558 example, if I want to put some numbers inside\n 1450 02:19:06,558 --> 02:19:13,439 brackets, let's say numbers is equal to, let's\n 1451 02:19:13,440 --> 02:19:20,000 curly braces, I can pass my values, let's\n 1452 02:19:20,000 --> 02:19:25,329 with different arrays, for loops can be very\n 1453 02:19:25,329 --> 02:19:30,229 your array. For example, if I want to print\n 1454 02:19:30,229 --> 02:19:35,250 I can say something like this, I can create\n 1455 02:19:35,250 --> 02:19:42,880 zero, i less than in this case, the size of\n 1456 02:19:42,880 --> 02:19:48,760 After that, let's say i plus plus. Inside\n 1457 02:19:48,760 --> 02:19:55,011 numbers with an index of I. This way, I am\n 1458 02:19:55,011 --> 02:19:59,489 numbers array before running the application.\n 1459 02:19:59,489 --> 02:20:05,569 that we Have a clean console. As you can see\n 1460 02:20:05,569 --> 02:20:10,629 into our console. So for loops are very helpful\n 1461 02:20:10,629 --> 02:20:16,170 arrays. In here, we have hard coded these\n 1462 02:20:16,170 --> 02:20:21,870 our array? For example, if we get some values\n 1463 02:20:21,870 --> 02:20:26,440 case, it might be possible that we don't know\n 1464 02:20:26,440 --> 02:20:30,980 loops with arrays, if you don't know the size\n 1465 02:20:30,979 --> 02:20:36,579 property of different areas. For example,\n 1466 02:20:36,579 --> 02:20:41,530 This way, we don't need to be worried about\n 1467 02:20:41,530 --> 02:20:46,980 like this. Let's run the application once\n 1468 02:20:46,979 --> 02:20:52,039 from one to six. Later on, we will see that\n 1469 02:20:52,040 --> 02:20:56,410 can also have different kinds of arrays for\n 1470 02:20:56,409 --> 02:21:02,200 classes in Java, but more on that later on.\n 1471 02:21:02,200 --> 02:21:08,750 of different items. But there are some limitations\n 1472 02:21:08,750 --> 02:21:13,560 after the definition is immutable. Let me\n 1473 02:21:13,560 --> 02:21:18,761 When we define our students array, we have\n 1474 02:21:18,762 --> 02:21:24,110 to change the size of our array, for example,\n 1475 02:21:24,110 --> 02:21:31,090 For example, if you say the students with\n 1476 02:21:31,090 --> 02:21:36,979 hover over these five, you can see that array\n 1477 02:21:36,979 --> 02:21:42,609 elements in here cannot fit in our array.\n 1478 02:21:42,610 --> 02:21:49,470 you should see a problem, let's say print\n 1479 02:21:49,469 --> 02:21:55,090 that, let's comment this line of code. Let's\n 1480 02:21:55,090 --> 02:21:59,420 getting an exception in here. Once again,\n 1481 02:21:59,420 --> 02:22:05,659 application crashes. And the exception type\n 1482 02:22:05,659 --> 02:22:11,629 which means that the sixth element does not\n 1483 02:22:11,629 --> 02:22:17,259 after you define them, you cannot change their\n 1484 02:22:17,260 --> 02:22:21,670 arrays in Java, there are others as well.\n 1485 02:22:21,670 --> 02:22:26,460 your arrays. later on. When we use other kinds\n 1486 02:22:26,459 --> 02:22:32,500 have all kinds of operations on our array\n 1487 02:22:32,500 --> 02:22:36,930 other kinds of collections in here because\n 1488 02:22:36,930 --> 02:22:42,220 after we know about object oriented programming.\n 1489 02:22:42,219 --> 02:22:47,840 other kinds of collections like array lists\n 1490 02:22:47,840 --> 02:22:52,819 I'm going to write a simple application in\n 1491 02:22:52,819 --> 02:22:58,750 learned about arrays. Before that, let me\n 1492 02:22:58,750 --> 02:23:03,969 start creating our application down in here.\n 1493 02:23:03,969 --> 02:23:09,299 the contacts application on the phone, I'm\n 1494 02:23:09,299 --> 02:23:14,519 names on a phone for to the user. And after\n 1495 02:23:14,520 --> 02:23:19,470 to give the user that contacts number. In\n 1496 02:23:19,469 --> 02:23:26,299 going to need a string array, let's say a\n 1497 02:23:26,299 --> 02:23:33,420 our names directly. Let's say Mesa. After\n 1498 02:23:33,420 --> 02:23:40,000 for that I'm going to create that integer\n 1499 02:23:40,000 --> 02:23:46,100 initialize our array. After that, I'm going\n 1500 02:23:46,100 --> 02:23:54,120 on the phone. So let's create a for loop.\n 1501 02:23:54,120 --> 02:24:01,570 that length, and i plus plus. let's print\n 1502 02:24:01,569 --> 02:24:08,529 print names with an index of I. After the\n 1503 02:24:08,530 --> 02:24:16,010 a name. So let's say print. Let's say please\n 1504 02:24:16,010 --> 02:24:23,569 So let's create that is equal to new scanner\n 1505 02:24:27,670 --> 02:24:33,850 is equal to a scanner dot next. Then I'm going\n 1506 02:24:33,850 --> 02:24:40,841 I'm going to find the index of the contact.\n 1507 02:24:40,841 --> 02:24:49,050 less than names, dot length, i plus plus.\n 1508 02:24:49,049 --> 02:24:57,759 say if name is equal to names with an index\n 1509 02:24:57,760 --> 02:25:05,510 going to print the contacts number for that\n 1510 02:25:05,510 --> 02:25:10,219 But right now there is a problem with my code,\n 1511 02:25:10,219 --> 02:25:15,010 or not, and that's because of these two equal\n 1512 02:25:15,010 --> 02:25:20,860 see if it's going to work. Let's enter our\n 1513 02:25:20,860 --> 02:25:26,329 can see, nothing has been printed. Let's talk\n 1514 02:25:26,329 --> 02:25:31,039 hover over the warning in here, it says that\n 1515 02:25:31,040 --> 02:25:37,340 signs not equal with a pair of parentheses.\n 1516 02:25:37,340 --> 02:25:43,270 two equal signs, you are checking for the\n 1517 02:25:43,270 --> 02:25:49,370 talking about the reference inside the devices\n 1518 02:25:49,370 --> 02:25:55,190 that variable allocates some space inside\n 1519 02:25:55,190 --> 02:26:01,131 a space has some address. And that allocated\n 1520 02:26:01,130 --> 02:26:06,689 comparing those two references in here together.\n 1521 02:26:06,690 --> 02:26:11,800 can be the same, but the reference might not\n 1522 02:26:11,799 --> 02:26:17,590 compare two strings by using these two equal\n 1523 02:26:17,591 --> 02:26:22,239 there is a better option for comparing two\n 1524 02:26:22,239 --> 02:26:28,489 see that as well. In here, I can say name,\n 1525 02:26:28,489 --> 02:26:35,000 can pass the other string. For example, I\n 1526 02:26:35,000 --> 02:26:39,511 from the previous videos, I said that the\n 1527 02:26:39,511 --> 02:26:45,530 are objects in Java. And because they are\n 1528 02:26:45,530 --> 02:26:51,200 For example, this equals method. Once again,\n 1529 02:26:51,200 --> 02:26:56,070 in the course when we talk about object oriented\n 1530 02:26:56,069 --> 02:27:02,149 is a method called equals in our string class,\n 1531 02:27:02,149 --> 02:27:08,649 of two strings by the values. So now, if you're\n 1532 02:27:08,649 --> 02:27:16,000 number. Let's run the application. In here,\n 1533 02:27:16,000 --> 02:27:20,040 see, we are getting the number. Let's also\n 1534 02:27:20,040 --> 02:27:26,170 Sarah is the second contact in our array.\n 1535 02:27:26,170 --> 02:27:30,930 is this number in which we have printed into\n 1536 02:27:30,930 --> 02:27:36,069 is working fine. Okay, I think that's enough\n 1537 02:27:36,069 --> 02:27:40,720 video. Finally, we are going to start talking\n 1538 02:27:40,720 --> 02:27:45,520 a very important topic, and it's going to\n 1539 02:27:45,520 --> 02:27:54,050 sure to Don't miss the next two or three videos.\n 1540 02:27:54,049 --> 02:27:58,219 As I said at the end of the previous video,\n 1541 02:27:58,219 --> 02:28:03,349 talking about object oriented programming.\n 1542 02:28:03,350 --> 02:28:08,399 we could have defined simple data types. For\n 1543 02:28:08,399 --> 02:28:15,180 could have say int number is equal to five,\n 1544 02:28:15,180 --> 02:28:19,840 texts, and all sorts of variables that we\n 1545 02:28:19,840 --> 02:28:25,180 what if we want to have a more complex data?\n 1546 02:28:25,180 --> 02:28:30,319 or a phone or every other object that you\n 1547 02:28:30,319 --> 02:28:35,670 the concept of object oriented programming.\n 1548 02:28:35,670 --> 02:28:42,479 your own objects, the core component of object\n 1549 02:28:42,479 --> 02:28:47,379 you can see that we are inside the class,\n 1550 02:28:47,379 --> 02:28:52,399 we can create our own class as well. Let me\n 1551 02:28:52,399 --> 02:28:58,750 create a new class. For example, inside my\n 1552 02:28:58,750 --> 02:29:04,290 I can right click and by selecting new Java\n 1553 02:29:04,290 --> 02:29:10,270 to name my class. For example, I can say phone,\n 1554 02:29:10,270 --> 02:29:16,390 to use upper cases for the first letter of\n 1555 02:29:16,389 --> 02:29:22,019 spaces or some strange characters as the name\n 1556 02:29:22,020 --> 02:29:27,000 to simply name my class form. Notice that\n 1557 02:29:27,000 --> 02:29:31,979 example interface and you know, later on we\n 1558 02:29:31,979 --> 02:29:38,379 create a class the one that has the CI con.\n 1559 02:29:38,379 --> 02:29:44,170 This is how a class looks like it lives inside\n 1560 02:29:44,170 --> 02:29:50,409 maker.org is section one. Also if you take\n 1561 02:29:50,409 --> 02:29:56,690 a new class has been added into our package.\n 1562 02:29:56,690 --> 02:30:03,540 Also every class has a name and besides This\n 1563 02:30:03,540 --> 02:30:08,220 access modifiers in few minutes. But for now\n 1564 02:30:08,219 --> 02:30:13,899 of curly braces in which we can put our code\n 1565 02:30:13,899 --> 02:30:18,840 an object. In this case, we are going to represent\n 1566 02:30:18,840 --> 02:30:24,819 objects can have different properties. For\n 1567 02:30:24,819 --> 02:30:30,619 have some amount of memory RAM, it can have\n 1568 02:30:30,620 --> 02:30:35,640 and all sorts of other properties that you\n 1569 02:30:35,639 --> 02:30:40,329 can have properties for your classes as well.\n 1570 02:30:40,329 --> 02:30:45,190 some properties to our phone class, we can\n 1571 02:30:45,190 --> 02:30:52,409 name. Now we define a property called name\n 1572 02:30:52,409 --> 02:30:57,329 the property of my class in here, I'm not\n 1573 02:30:57,329 --> 02:31:02,819 when we declare a class, we can reuse that\n 1574 02:31:02,819 --> 02:31:07,840 that class with different properties. For\n 1575 02:31:07,840 --> 02:31:13,219 would be iPhone, if we define another phone,\n 1576 02:31:13,219 --> 02:31:18,090 So for that reason, I'm not initializing the\n 1577 02:31:18,091 --> 02:31:25,030 properties to our phone object, let's say\n 1578 02:31:25,030 --> 02:31:32,630 memory Ram. After that, let's say int camera.\n 1579 02:31:32,629 --> 02:31:38,009 we can instantiate it, we know for sure that\n 1580 02:31:38,010 --> 02:31:43,319 main method inside our main class. So if I\n 1581 02:31:43,319 --> 02:31:48,569 it in here. And here is how you can create\n 1582 02:31:48,569 --> 02:31:53,940 of your class, you can see that when I typed\n 1583 02:31:53,940 --> 02:31:59,680 from IntelliJ. Sometimes you may get multiple\n 1584 02:31:59,680 --> 02:32:04,800 with different names can live in different\n 1585 02:32:04,800 --> 02:32:09,649 at the package that your object lives in.\n 1586 02:32:09,649 --> 02:32:15,629 class. After that you need to name your instance\n 1587 02:32:15,629 --> 02:32:22,000 say is equal to new phone. This way with the\n 1588 02:32:22,000 --> 02:32:27,739 new instance of our object. Now that we have\n 1589 02:32:27,739 --> 02:32:32,920 access to the properties of our objects our\n 1590 02:32:32,920 --> 02:32:39,590 some property for our class, we can say something\n 1591 02:32:39,590 --> 02:32:42,851 name is equal to let's name it iPhone 11. 1592 02:32:42,851 --> 02:32:49,860 With the help of this dot operator, you can\n 1593 02:32:49,860 --> 02:32:56,130 be precise all of the fields of your class.\n 1594 02:32:56,129 --> 02:33:00,529 properties or fields, you can also get those\n 1595 02:33:00,530 --> 02:33:04,829 can get them. For example, if you want to\n 1596 02:33:04,829 --> 02:33:10,829 like this, we can say print, iPhone dot name.\n 1597 02:33:10,829 --> 02:33:17,440 iPhone 11 printed into our console. And here\n 1598 02:33:17,440 --> 02:33:22,840 access to all of the fields of your class.\n 1599 02:33:22,840 --> 02:33:28,840 RAM is equal to eight. Beside properties,\n 1600 02:33:28,840 --> 02:33:33,389 For example, in the case of a phone, you can\n 1601 02:33:33,389 --> 02:33:38,549 call somebody. If you want to define some\n 1602 02:33:38,549 --> 02:33:43,090 let's see them as built. Let's switch back\n 1603 02:33:43,090 --> 02:33:49,180 a method I'm going to write the syntax and\n 1604 02:33:49,180 --> 02:33:54,620 all, our method has a name in this case its\n 1605 02:33:54,620 --> 02:33:59,530 have an access modifier like we did for the\n 1606 02:33:59,530 --> 02:34:04,511 this public in a minute. After that every\n 1607 02:34:04,511 --> 02:34:09,591 in this case, we are getting a string called\n 1608 02:34:09,591 --> 02:34:14,680 we need to pass some input to this method.\n 1609 02:34:14,680 --> 02:34:19,610 method, you can just pass a pair of empty\n 1610 02:34:19,610 --> 02:34:24,630 one or more inputs. If you want to have multiple\n 1611 02:34:24,629 --> 02:34:30,889 inputs with a comma. For example in here I\n 1612 02:34:30,889 --> 02:34:35,969 to do that in here. But you can have as many\n 1613 02:34:35,969 --> 02:34:42,639 and also an access modifier. Every method\n 1614 02:34:42,639 --> 02:34:47,969 but if you want you can change it. For example,\n 1615 02:34:47,969 --> 02:34:54,039 your method. You can also have integers or\n 1616 02:34:54,040 --> 02:34:59,230 you can return another class with your method.\n 1617 02:34:59,229 --> 02:35:05,219 to return any From your method, you can use\n 1618 02:35:05,219 --> 02:35:10,340 talk more about the return type of every method\n 1619 02:35:10,340 --> 02:35:14,760 return anything from this method. So we are\n 1620 02:35:14,760 --> 02:35:20,200 of my method, I can put my code for example,\n 1621 02:35:20,200 --> 02:35:26,730 or at least I'm going to print something.\n 1622 02:35:28,180 --> 02:35:34,590 Now that I have created this method, I can\n 1623 02:35:34,590 --> 02:35:40,889 my object. For example, in here I can see\n 1624 02:35:40,889 --> 02:35:46,479 see that by typing dots, I can have access\n 1625 02:35:46,479 --> 02:35:51,850 error error in here. And that's because when\n 1626 02:35:51,850 --> 02:35:57,050 for it. So when I'm going to use my method,\n 1627 02:35:57,049 --> 02:36:02,770 say our beings are bearing the name of a track.\n 1628 02:36:02,771 --> 02:36:08,800 happen, you can see that we are playing some\n 1629 02:36:08,799 --> 02:36:14,219 behaviors for your classes, there are a few\n 1630 02:36:14,219 --> 02:36:19,889 that you can reuse your method. For example,\n 1631 02:36:19,889 --> 02:36:26,899 iPhone dot play music, and I can pass a different\n 1632 02:36:26,899 --> 02:36:33,590 time. If we run our application, you can see\n 1633 02:36:33,590 --> 02:36:39,850 a time. So the first benefit of using methods\n 1634 02:36:39,850 --> 02:36:46,030 for organizing our code. For example, imagine\n 1635 02:36:46,030 --> 02:36:51,880 you can pass all the codes for that calculation\n 1636 02:36:51,879 --> 02:36:57,009 you can pass all of those calculations to\n 1637 02:36:57,010 --> 02:37:02,050 method in order to do the calculation, it's\n 1638 02:37:02,049 --> 02:37:07,969 code. Also, by using methods, you can encapsulate\n 1639 02:37:07,969 --> 02:37:14,060 later videos. But in here inside your class,\n 1640 02:37:14,060 --> 02:37:19,011 that method will be accessible only from your\n 1641 02:37:19,011 --> 02:37:23,631 If you go back to main class, you can see\n 1642 02:37:23,630 --> 02:37:30,619 over there, it says that this method has private\n 1643 02:37:30,620 --> 02:37:36,590 encapsulate different behaviors for your own\n 1644 02:37:36,590 --> 02:37:41,649 modifier. You can have access modifiers, for\n 1645 02:37:41,649 --> 02:37:47,000 the fields of your classes, I can make this\n 1646 02:37:47,000 --> 02:37:53,819 we have three kind of access modifiers, we\n 1647 02:37:53,819 --> 02:37:59,639 protected if you don't use anything as the\n 1648 02:37:59,639 --> 02:38:05,649 public. So there is no difference between\n 1649 02:38:05,649 --> 02:38:11,229 When you use public as the access modifier.\n 1650 02:38:11,229 --> 02:38:16,969 that this field is going to be accessible\n 1651 02:38:16,969 --> 02:38:22,429 in here, let's say private, if I go back to\n 1652 02:38:22,430 --> 02:38:28,761 a red warning, it means that we can no longer\n 1653 02:38:28,761 --> 02:38:35,090 modifier of our field or method, that field\n 1654 02:38:35,090 --> 02:38:40,101 class, beside public and private we also have\n 1655 02:38:40,101 --> 02:38:45,180 later on in the course both private and public\n 1656 02:38:45,180 --> 02:38:49,889 going to use in the course for the access\n 1657 02:38:49,889 --> 02:38:54,970 private admin group inside there. But usually\n 1658 02:38:54,970 --> 02:38:59,449 that we are getting a red warning in here.\n 1659 02:38:59,450 --> 02:39:05,260 not allowed in here. Do you use private mostly\n 1660 02:39:05,260 --> 02:39:11,159 inner classes later on in future videos. But\n 1661 02:39:11,159 --> 02:39:16,930 other classes. When you define them as private\n 1662 02:39:16,930 --> 02:39:22,470 classes from the parent class. We will talk\n 1663 02:39:22,469 --> 02:39:26,969 classes. For now let's just change this one\n 1664 02:39:26,969 --> 02:39:32,260 private as the access modifier of your fields\n 1665 02:39:32,260 --> 02:39:39,180 want to limit the access of your fields or\n 1666 02:39:39,180 --> 02:39:44,090 classes. For example, imagine that you are\n 1667 02:39:44,090 --> 02:39:50,210 for other developers. In that case, you may\n 1668 02:39:50,209 --> 02:39:55,109 For that reason, you may want to change the\n 1669 02:39:55,110 --> 02:40:00,750 to private but now that we have defined the\n 1670 02:40:00,750 --> 02:40:05,879 how can we have access to this name from outside\n 1671 02:40:05,879 --> 02:40:11,139 quickly talk about it, we can create public\n 1672 02:40:11,139 --> 02:40:16,659 say public as the return type of this method,\n 1673 02:40:16,659 --> 02:40:22,091 method, I'm going to say set name. As you\n 1674 02:40:22,091 --> 02:40:27,370 getting some suggestions from IntelliJ. Basically,\n 1675 02:40:27,370 --> 02:40:33,271 set the name of the setter methods like this,\n 1676 02:40:33,271 --> 02:40:37,810 convention. But of course, you can name them\n 1677 02:40:37,809 --> 02:40:42,680 to follow the convention. So I'm going to\n 1678 02:40:42,680 --> 02:40:45,190 input of this method, I'm going to say 1679 02:40:45,190 --> 02:40:52,520 the string, let's say name. Inside this method,\n 1680 02:40:52,520 --> 02:40:58,920 to whatever the name that I'm going to receive\n 1681 02:40:58,920 --> 02:41:05,180 name is equal to name, the keyword, this is\n 1682 02:41:05,180 --> 02:41:10,680 in. For example, right now we are inside our\n 1683 02:41:10,680 --> 02:41:17,130 this dot name, we are accessing the property\n 1684 02:41:17,129 --> 02:41:22,629 here is the input of our method. So we are\n 1685 02:41:22,629 --> 02:41:28,549 we receive, we are the input of this method.\n 1686 02:41:28,549 --> 02:41:34,449 is public, we can use it inside other classes.\n 1687 02:41:34,450 --> 02:41:38,970 we want to set the name of our iPhone, we\n 1688 02:41:38,969 --> 02:41:45,560 delete this line of code. We can say iPhone\n 1689 02:41:45,560 --> 02:41:51,681 of this method, I need to pass the name of\n 1690 02:41:51,681 --> 02:41:58,230 I don't have access to the field directly.\n 1691 02:41:58,229 --> 02:42:03,449 value of that field. But what if we want to\n 1692 02:42:03,450 --> 02:42:09,091 write another method. And here is how we can\n 1693 02:42:09,091 --> 02:42:14,640 return type of this method, I'm not going\n 1694 02:42:14,639 --> 02:42:19,970 name. So I'm going to say a string. Once again,\n 1695 02:42:19,970 --> 02:42:26,090 get name, we don't need anything as the input.\n 1696 02:42:26,090 --> 02:42:32,510 something. And here is how you can return\n 1697 02:42:32,510 --> 02:42:36,909 that, whatever you are going to return. In\n 1698 02:42:36,909 --> 02:42:43,220 So I'm going to say this dot name. Once again,\n 1699 02:42:43,220 --> 02:42:49,090 names means the name inside our phone object.\n 1700 02:42:49,090 --> 02:42:54,360 our main class, instead of saying iPhone dot\n 1701 02:42:54,360 --> 02:43:01,680 say, iPhone dot get name. If we run our application,\n 1702 02:43:01,680 --> 02:43:07,880 form. Let's run the application. You can see\n 1703 02:43:07,879 --> 02:43:13,389 these kinds of methods ourselves, we have\n 1704 02:43:13,389 --> 02:43:19,510 can use the help of our ID, we can right click\n 1705 02:43:19,510 --> 02:43:24,228 Similarly, we can press ALT plus insert, you\n 1706 02:43:24,228 --> 02:43:30,260 We have getter, we have surfer, and also we\n 1707 02:43:30,260 --> 02:43:35,460 getters and setters, we can select that. After\n 1708 02:43:35,459 --> 02:43:41,309 to create getters and setters for for example,\n 1709 02:43:41,309 --> 02:43:46,829 see that Id has created some codes for us,\n 1710 02:43:46,829 --> 02:43:52,930 identical to the methods that we created above\n 1711 02:43:52,930 --> 02:43:58,590 methods are very usual, Id can help us with\n 1712 02:43:58,590 --> 02:44:04,479 getters and setters? Well, there are a few\n 1713 02:44:04,479 --> 02:44:09,500 Let's quickly talk about that a bit. For example,\n 1714 02:44:09,500 --> 02:44:15,200 to change the value of our fields, we can\n 1715 02:44:15,200 --> 02:44:21,240 give them the permission to get the value\n 1716 02:44:21,239 --> 02:44:27,079 or vice versa, we can create setter methods\n 1717 02:44:27,079 --> 02:44:33,021 value of our properties from other classes,\n 1718 02:44:33,021 --> 02:44:38,780 The first reason is encapsulation. The other\n 1719 02:44:38,780 --> 02:44:44,340 getter methods, you may want to do some other\n 1720 02:44:44,340 --> 02:44:49,630 setting a name for your phone, you may want\n 1721 02:44:49,629 --> 02:44:55,329 that case, you can have some validation before\n 1722 02:44:55,329 --> 02:44:59,690 that's enough talking about getters and setters.\n 1723 02:44:59,690 --> 02:45:05,550 of have these two private, and let's create\n 1724 02:45:05,549 --> 02:45:11,189 create any. down in here after everything,\n 1725 02:45:11,190 --> 02:45:15,920 say getters and setters. And let's select\n 1726 02:45:15,920 --> 02:45:20,840 created these codes for us. But because we\n 1727 02:45:20,840 --> 02:45:26,309 ram to private, now we have an error inside\n 1728 02:45:26,309 --> 02:45:31,059 iPhone dot memory is equal to eight, I can\n 1729 02:45:31,059 --> 02:45:37,478 dot cert memory. And I can pass eight. What\n 1730 02:45:37,478 --> 02:45:43,600 objects, we have defined our object. After\n 1731 02:45:43,601 --> 02:45:48,560 object, there is another way of instantiating\n 1732 02:45:48,559 --> 02:45:54,309 So if I switch back to my phone class, above\n 1733 02:45:54,309 --> 02:46:00,100 called constructor. Let's use the help of\n 1734 02:46:00,101 --> 02:46:05,550 I'm going to go to generate menu. The first\n 1735 02:46:05,549 --> 02:46:10,139 to select all of the fields. And I'm going\n 1736 02:46:10,139 --> 02:46:15,680 has been generated for us this is called a\n 1737 02:46:15,680 --> 02:46:22,050 Our constructor needs to have public as its\n 1738 02:46:22,049 --> 02:46:27,920 that the return type of this constructor is\n 1739 02:46:27,920 --> 02:46:33,219 constructor does not have any name. And as\n 1740 02:46:33,219 --> 02:46:38,969 all of the fields of our class we are receiving\n 1741 02:46:38,969 --> 02:46:44,309 our constructor we are assigning different\n 1742 02:46:44,309 --> 02:46:49,299 to the fields of our class. Now that we have\n 1743 02:46:49,299 --> 02:46:54,429 our main class, we can see that we are getting\n 1744 02:46:54,430 --> 02:47:00,159 expected four arguments both found zero, it\n 1745 02:47:00,159 --> 02:47:06,090 we need to pass the values directly to the\n 1746 02:47:06,090 --> 02:47:09,799 how you can pass them. The first one was the\nname of our phone 1747 02:47:09,799 --> 02:47:16,909 let's say iPhone 11. I don't remember the\n 1748 02:47:16,909 --> 02:47:22,250 size, let's say five, I believe the next one\n 1749 02:47:22,250 --> 02:47:27,819 one was camera, let's say eight as well. Now\n 1750 02:47:27,819 --> 02:47:33,719 this, we don't need to directly set fields\n 1751 02:47:33,719 --> 02:47:39,029 let's delete this as well. In this line, we\n 1752 02:47:39,030 --> 02:47:43,720 run the application and see if we can print\n 1753 02:47:43,719 --> 02:47:48,659 11 has been printed. So when you are using\n 1754 02:47:48,659 --> 02:47:54,829 of different properties at the time of instantiating\n 1755 02:47:54,829 --> 02:48:00,030 constructors as well. For example, if I come\n 1756 02:48:00,030 --> 02:48:06,380 and go to the Generate menu. If I select konstruktor,\n 1757 02:48:06,379 --> 02:48:11,799 example, in this case, I'm going to select\n 1758 02:48:11,799 --> 02:48:17,069 can see that we have another constructor which\n 1759 02:48:17,069 --> 02:48:21,969 if you hover over this phone, you can see\n 1760 02:48:21,969 --> 02:48:27,469 switch back to our main class, we can create\n 1761 02:48:27,469 --> 02:48:33,269 Let's quickly do that. I'm going to do that\n 1762 02:48:33,270 --> 02:48:38,540 And this is the beauty of object oriented\n 1763 02:48:38,540 --> 02:48:43,430 can reuse that class as many times as you\n 1764 02:48:43,430 --> 02:48:50,511 an entirely new font. Let's name this one\n 1765 02:48:50,511 --> 02:48:55,360 time I'm going to use the second constructor\n 1766 02:48:55,360 --> 02:49:01,829 and four the memory, I'm going to say 16 you\n 1767 02:49:01,829 --> 02:49:08,319 of defining a new phone. Now we have two different\n 1768 02:49:08,319 --> 02:49:14,110 kinds of constructors for a class is called\n 1769 02:49:14,110 --> 02:49:18,530 types as well. We will talk about it later\n 1770 02:49:18,530 --> 02:49:23,920 the video in here. In the next video we are\n 1771 02:49:23,920 --> 02:49:28,649 programming. There are many more things left\n 1772 02:49:28,649 --> 02:49:38,180 next video. In the previous video, we have\n 1773 02:49:38,180 --> 02:49:44,220 how can we create them and also what are the\n 1774 02:49:44,219 --> 02:49:50,129 going to talk about some important concepts\n 1775 02:49:50,129 --> 02:49:55,720 The first of those concepts is inheritance.\n 1776 02:49:55,720 --> 02:50:01,459 example because I think that would make everything\n 1777 02:50:01,459 --> 02:50:07,759 to create a class called doc. For this doc\n 1778 02:50:07,760 --> 02:50:14,639 For example, I'm going to define a name, let's\n 1779 02:50:14,639 --> 02:50:22,819 to define a color, let's say private string\n 1780 02:50:22,819 --> 02:50:29,728 let's say private int, legs. And also I'm\n 1781 02:50:29,728 --> 02:50:38,020 if a dog has a tail or not, so let's say private\n 1782 02:50:38,021 --> 02:50:43,551 create a constructor for our class by pressing\n 1783 02:50:43,550 --> 02:50:49,689 here. Let's select all of the fields. Let's\n 1784 02:50:49,690 --> 02:50:55,069 class as well, once again, by pressing ALT\n 1785 02:50:55,069 --> 02:51:00,629 setter, we can create getters and setters.\n 1786 02:51:00,629 --> 02:51:07,049 well. I'm going to say public void, let's\n 1787 02:51:07,049 --> 02:51:13,479 the eating behavior of a dog. As the input\n 1788 02:51:13,479 --> 02:51:19,670 So let's say let's drink food. And inside\n 1789 02:51:19,670 --> 02:51:26,690 let's say eating class our food. Okay, nothing\n 1790 02:51:26,690 --> 02:51:32,010 have created these four fields. After that\n 1791 02:51:32,010 --> 02:51:37,690 our getters and setters. And we have created\n 1792 02:51:37,690 --> 02:51:44,050 I'm doing all of this, let's also create another\n 1793 02:51:44,049 --> 02:51:51,509 bird class, let's also have a name. Also,\n 1794 02:51:51,510 --> 02:51:58,159 fields, one for the number of legs, private\n 1795 02:51:58,159 --> 02:52:04,039 that if our bird has a tail or not, so let's\n 1796 02:52:04,040 --> 02:52:11,080 let's say has, for this bird class, let's\n 1797 02:52:11,079 --> 02:52:17,680 and setters. I'm going to create my eath method\n 1798 02:52:19,729 --> 02:52:26,750 Let's get the name of our food. And inside\n 1799 02:52:26,750 --> 02:52:32,959 say eating that food. You probably can see\n 1800 02:52:32,959 --> 02:52:39,179 between our bird and dog class. Both of those\n 1801 02:52:39,180 --> 02:52:44,180 they have all of these getters and setters.\n 1802 02:52:44,180 --> 02:52:49,430 programming, this is not efficient, you basically\n 1803 02:52:49,430 --> 02:52:55,559 of defining our bird and dot class like this,\n 1804 02:52:55,559 --> 02:53:00,510 oriented programming called inheritance. For\n 1805 02:53:00,510 --> 02:53:06,470 animal class. And after that, I will extend\n 1806 02:53:06,470 --> 02:53:12,029 see how we can do that inside my package,\n 1807 02:53:12,030 --> 02:53:17,850 say animal. First of all, let's add some fields,\n 1808 02:53:17,850 --> 02:53:24,290 Let's also copy them from here. And after\n 1809 02:53:24,290 --> 02:53:30,470 and setters and our eat method. Don't worry,\n 1810 02:53:30,469 --> 02:53:39,180 in a minute, let's say public, void eat string\n 1811 02:53:39,181 --> 02:53:45,659 of our foot. Now that we have created this\n 1812 02:53:45,659 --> 02:53:51,271 is going to be much simpler. For that I'm\n 1813 02:53:51,271 --> 02:53:57,130 bird class. Let's delete all of them. This\n 1814 02:53:57,129 --> 02:54:03,719 and constructors and methods, I'm going to\n 1815 02:54:03,719 --> 02:54:08,879 that our bird is an animal, we are extending\n 1816 02:54:08,879 --> 02:54:13,549 we can customize our birth class as well.\n 1817 02:54:13,549 --> 02:54:18,139 a red warning. And the warning in here it\n 1818 02:54:18,139 --> 02:54:23,010 available in this package. Basically, it says\n 1819 02:54:23,010 --> 02:54:28,141 ALT plus insert in here. And let's select\n 1820 02:54:28,141 --> 02:54:32,989 generated this constructor you can also see\n 1821 02:54:32,989 --> 02:54:38,601 in our birth class, we are receiving some\n 1822 02:54:38,601 --> 02:54:44,770 has rather a strange syntax. We haven't seen\n 1823 02:54:44,770 --> 02:54:49,399 super keyword means that do whatever you're\n 1824 02:54:49,399 --> 02:54:55,889 class. In this case, our parent class is animal.\n 1825 02:54:55,889 --> 02:55:02,379 to the constructor of our animal class. It\n 1826 02:55:02,379 --> 02:55:07,909 the fields of our animal. Now that I have\n 1827 02:55:07,909 --> 02:55:12,601 to instantiate it, for example, inside the\n 1828 02:55:12,601 --> 02:55:19,730 bird. Let's name it Phoenix, let's say is\n 1829 02:55:19,729 --> 02:55:25,069 constructor is waiting for our arguments.\n 1830 02:55:25,069 --> 02:55:31,569 Nina, we need the color, let's say golden.\n 1831 02:55:31,569 --> 02:55:37,600 I'm going to pass to, and a Boolean indicating\n 1832 02:55:37,600 --> 02:55:43,020 through. Once again, remember that in our\n 1833 02:55:43,020 --> 02:55:48,819 But in my main class, if I want, I can use\n 1834 02:55:48,819 --> 02:55:53,399 in this case, animal. For example, if I want\n 1835 02:55:53,399 --> 02:55:58,911 like this, I can say Phoenix dot get name,\n 1836 02:55:58,911 --> 02:56:05,569 methods. Let's run the application. And let's\n 1837 02:56:05,569 --> 02:56:10,260 you can see that the name has been printed\n 1838 02:56:10,260 --> 02:56:14,940 you can also have access to all of the other\n 1839 02:56:14,940 --> 02:56:20,690 if you remember inside the animal class, we\n 1840 02:56:20,690 --> 02:56:24,770 we can use it in our bird instance. For example,\n 1841 02:56:24,770 --> 02:56:33,260 Pheonix, that it, I don't know what Phoenix\n 1842 02:56:33,260 --> 02:56:38,260 run our application. And let's see if we can\n 1843 02:56:38,260 --> 02:56:43,460 you can see in here, Nina is eating meat.\n 1844 02:56:43,459 --> 02:56:48,279 you can also change the dog class as well.\n 1845 02:56:48,280 --> 02:56:54,770 all of these codes once again. Instead, I'm\n 1846 02:56:54,770 --> 02:56:59,920 let's say extends animal, you can see the\n 1847 02:56:59,920 --> 02:57:04,710 constructor, you can see that the amount of\n 1848 02:57:04,709 --> 02:57:10,609 is a lot less right now, the bird and dog\n 1849 02:57:10,610 --> 02:57:16,260 for sure that a dog and a bird are not the\n 1850 02:57:16,260 --> 02:57:21,540 other behaviors as well. If you want, you\n 1851 02:57:21,540 --> 02:57:27,470 For example, inside my birth class, I want\n 1852 02:57:27,469 --> 02:57:33,978 let's say ain't veins, we know that dogs do\n 1853 02:57:33,978 --> 02:57:38,350 this constructor and I'm going to create it\n 1854 02:57:38,351 --> 02:57:44,510 of my ID, let's press ALT plus insert. In\n 1855 02:57:44,510 --> 02:57:49,649 as you can see, the constructor has been changed\n 1856 02:57:49,649 --> 02:57:54,959 same it means that do whatever you're doing\n 1857 02:57:54,959 --> 02:58:00,549 inside our parent class inside the animal\n 1858 02:58:00,549 --> 02:58:06,039 wings hasn't been passed to this super statement.\n 1859 02:58:06,040 --> 02:58:11,340 inside the constructor of this bird class.\n 1860 02:58:11,340 --> 02:58:16,950 Right now the duck does not have any wings\n 1861 02:58:16,950 --> 02:58:21,490 if I switch back to my main class, I should\n 1862 02:58:21,489 --> 02:58:26,920 that you need to pass a wink that's also fascinating\n 1863 02:58:26,920 --> 02:58:32,530 to we can also create getter and setter methods\n 1864 02:58:32,530 --> 02:58:38,561 our bird class down in here, let's press up\n 1865 02:58:38,560 --> 02:58:44,289 Now that we have created the getters and setters,\n 1866 02:58:44,290 --> 02:58:51,080 For example, down in here, I'm going to say\n 1867 02:58:51,079 --> 02:58:56,969 And you can see that two has been printed\n 1868 02:58:56,969 --> 02:59:01,889 methods. You can also have other methods inside\n 1869 02:59:01,889 --> 02:59:07,599 the spirit class, if I want, I can define\n 1870 02:59:11,101 --> 02:59:16,569 I'm not going to receive anything as the input\n 1871 02:59:16,569 --> 02:59:22,889 dot get name. Also if you remember from the\n 1872 02:59:22,889 --> 02:59:27,569 to the current object that you are in. In\n 1873 02:59:27,569 --> 02:59:33,260 have any getname method. But because we are\n 1874 02:59:33,260 --> 02:59:39,710 start getting, let's say is flying. So besides\n 1875 02:59:39,709 --> 02:59:45,039 child classes with different methods. Let's\n 1876 02:59:45,040 --> 02:59:51,510 our main class, let's say Phoenix dot fly.\n 1877 02:59:51,510 --> 02:59:57,110 the finding new methods inside your child\n 1878 02:59:57,110 --> 03:00:01,489 methods of your parent class. For example,\n 1879 03:00:01,489 --> 03:00:06,329 we had this eat method, I'm talking about\n 1880 03:00:06,329 --> 03:00:11,450 saying eating food inside our bird class.\n 1881 03:00:11,450 --> 03:00:16,960 right in here, I'm going to press Ctrl plus\n 1882 03:00:16,959 --> 03:00:22,689 of different methods, I'm going to override\n 1883 03:00:22,690 --> 03:00:28,489 going to say that I'm going to change the\n 1884 03:00:28,489 --> 03:00:33,478 inside the parent class. Once again, we are\n 1885 03:00:33,478 --> 03:00:37,879 whatever you're doing with this parameter\n 1886 03:00:37,879 --> 03:00:42,869 can delete this super statement completely,\n 1887 03:00:42,870 --> 03:00:48,281 later on. After this super keyword. I'm going\n 1888 03:00:48,281 --> 03:00:53,760 just say eating finished. So this way, we\n 1889 03:00:53,760 --> 03:00:59,290 inside our child class from what it was inside\n 1890 03:00:59,290 --> 03:01:04,160 class, we have executed this line of code\n 1891 03:01:04,159 --> 03:01:09,659 after that, so that we can see what's going\n 1892 03:01:09,659 --> 03:01:14,569 run the application, you can see that we are\n 1893 03:01:14,569 --> 03:01:19,199 finished, if you want to completely change\n 1894 03:01:19,200 --> 03:01:24,460 class, you can simply delete this super that\n 1895 03:01:24,459 --> 03:01:31,169 to say chewing food instead of eating fruit.\n 1896 03:01:31,170 --> 03:01:36,000 this eighth method, but their behavior is\n 1897 03:01:36,000 --> 03:01:41,129 if we can see the difference, we can see that\n 1898 03:01:41,129 --> 03:01:47,519 is called inheritance in object oriented programming.\n 1899 03:01:47,520 --> 03:01:53,399 animal class. You can also continue this inheritance\n 1900 03:01:53,399 --> 03:01:59,299 you can inherit the dog object. Let's quickly\n 1901 03:01:59,299 --> 03:02:06,239 let's say Shephard. Now in here, I can say\n 1902 03:02:06,239 --> 03:02:11,549 again, we are getting this red warning. Let's\n 1903 03:02:11,549 --> 03:02:16,770 that problem, we can see that even though\n 1904 03:02:16,771 --> 03:02:22,590 But inside our Shephard class in the constructor,\n 1905 03:02:22,590 --> 03:02:27,690 parent of this Shephard class, which is dog\n 1906 03:02:27,690 --> 03:02:33,300 So you can do this inheritance as many times\n 1907 03:02:33,299 --> 03:02:38,340 and extend the shefford class. But I don't\n 1908 03:02:38,340 --> 03:02:43,478 to say that you have that option. Okay, I\n 1909 03:02:43,478 --> 03:02:48,639 The other concept that I'm going to talk about\n 1910 03:02:48,639 --> 03:02:53,689 about polymorphism in the previous video,\n 1911 03:02:53,690 --> 03:03:00,190 previous video, I said that one kind of polymorphism\n 1912 03:03:00,190 --> 03:03:06,180 for example, inside our animal class, if we\n 1913 03:03:06,180 --> 03:03:12,181 accept different number of fields. For example,\n 1914 03:03:12,181 --> 03:03:17,229 this is one kind of polymorphism. Now we can\n 1915 03:03:17,228 --> 03:03:23,359 ways. Basically, polymorphism means having\n 1916 03:03:23,360 --> 03:03:28,470 of polymorphism. But before we talk about\n 1917 03:03:28,469 --> 03:03:33,539 sure that if you're going to need that the\n 1918 03:03:33,540 --> 03:03:39,100 so far is about this eat method. So inside\n 1919 03:03:39,100 --> 03:03:43,960 but also we had it inside the child class,\n 1920 03:03:43,959 --> 03:03:48,459 have different forms, it means that we are\n 1921 03:03:48,459 --> 03:03:54,519 these methods. This is another kind of polymorphism\n 1922 03:03:54,520 --> 03:04:00,569 that are doing the same job differently. We\n 1923 03:04:00,569 --> 03:04:06,020 that's with the methods themselves. We don't\n 1924 03:04:06,020 --> 03:04:12,360 class. But in here, we can also have another\n 1925 03:04:12,360 --> 03:04:16,970 how we can create another method called flight.\n 1926 03:04:19,239 --> 03:04:24,850 time inside the parentheses, I'm going to\n 1927 03:04:24,850 --> 03:04:30,909 to receive a speed as you can see, the compiler\n 1928 03:04:30,909 --> 03:04:36,159 methods with the same name. Now, if I switch\n 1929 03:04:36,159 --> 03:04:40,690 are not getting an error but before that,\n 1930 03:04:40,690 --> 03:04:45,670 Even though we are not getting error warning\n 1931 03:04:45,670 --> 03:04:50,770 first flow method Let me close all of the\n 1932 03:04:50,770 --> 03:04:55,770 we are using the first method, but if we want\n 1933 03:04:55,770 --> 03:05:00,860 pass some arguments in here. For example,\n 1934 03:05:00,860 --> 03:05:06,229 same name when we have different number of\n 1935 03:05:06,228 --> 03:05:11,920 different kinds of arguments, for example,\n 1936 03:05:11,920 --> 03:05:17,809 if we had another method, for example, in\n 1937 03:05:17,809 --> 03:05:24,500 the fly name as well. Let's see that briefly,\n 1938 03:05:24,500 --> 03:05:29,860 parentheses, I don't know, let's pass a string.\n 1939 03:05:29,860 --> 03:05:35,440 compiler is happy with this way of defining\n 1940 03:05:35,440 --> 03:05:41,190 difference in the number of parameters, the\n 1941 03:05:41,190 --> 03:05:46,899 in here is also called polymorphism. using\n 1942 03:05:46,899 --> 03:05:51,109 okay, let's delete these two, I don't think\n 1943 03:05:51,110 --> 03:05:55,370 a good point to stop the video in here. In\n 1944 03:05:55,370 --> 03:06:00,170 start talking about composition in object\n 1945 03:06:00,170 --> 03:06:09,530 video. In the previous video, we have talked\n 1946 03:06:09,530 --> 03:06:14,860 video, we are going to talk about composition\n 1947 03:06:14,860 --> 03:06:20,260 videos, I said that classes are useful for\n 1948 03:06:20,260 --> 03:06:25,780 type. For example, imagine that you are going\n 1949 03:06:25,780 --> 03:06:31,180 systems, for example, you have a system for\n 1950 03:06:31,180 --> 03:06:37,181 engine, it can also have a fuel system. If\n 1951 03:06:37,181 --> 03:06:42,850 you can create different classes, for example,\n 1952 03:06:42,850 --> 03:06:48,351 field system. And after that inside your car\n 1953 03:06:48,351 --> 03:06:54,489 to have a car, let's see how we can use composition\n 1954 03:06:54,489 --> 03:07:00,511 a class called engine. For this engine, I'm\n 1955 03:07:00,511 --> 03:07:05,940 going to define a model. So let's say private\n 1956 03:07:05,940 --> 03:07:13,171 integer, private int. I'm going to name this\n 1957 03:07:13,171 --> 03:07:17,790 it's just a property of different engines.\n 1958 03:07:17,790 --> 03:07:22,630 these two would be enough. After that, let's\n 1959 03:07:22,629 --> 03:07:28,149 and setters. Let's create a car class. And\n 1960 03:07:28,149 --> 03:07:34,329 that, let's say new Java class. Let's name\n 1961 03:07:34,329 --> 03:07:37,539 four fields. First of all, let's pass a name 1962 03:07:37,540 --> 03:07:44,370 private string name. After that, let's have\n 1963 03:07:44,370 --> 03:07:51,150 that, let's define the color of our car private\n 1964 03:07:51,149 --> 03:07:56,859 include or compose an engine in here. For\n 1965 03:07:56,860 --> 03:08:02,430 capital E. And in here, you can see that in\n 1966 03:08:02,430 --> 03:08:07,690 import that into this class. Let's name it\n 1967 03:08:07,690 --> 03:08:12,819 composed only one class inside this class.\n 1968 03:08:12,819 --> 03:08:18,659 for a stereo system and your system and everything\n 1969 03:08:18,659 --> 03:08:25,209 my point. If I use only one class after death\n 1970 03:08:25,209 --> 03:08:30,519 you can see that this engine has been passed\n 1971 03:08:30,520 --> 03:08:35,800 passed other data types like integers and\n 1972 03:08:35,799 --> 03:08:41,769 the same way that we had for previous classes.\n 1973 03:08:41,770 --> 03:08:46,819 instantiate it. For example, inside our main\n 1974 03:08:46,819 --> 03:08:53,959 object in here, I can say car, let's name\n 1975 03:08:53,959 --> 03:08:59,978 see, the constructor in here requires four\n 1976 03:08:59,978 --> 03:09:06,869 for the name. I'm going to pass Mercedes AMG\n 1977 03:09:06,870 --> 03:09:12,070 the color, let's say silver. What What should\n 1978 03:09:12,069 --> 03:09:17,670 our engine in two ways. First of all, we can\n 1979 03:09:17,670 --> 03:09:23,771 For example, in here I can say engine, let's\n 1980 03:09:23,771 --> 03:09:28,790 I can pass a model and RPM for this engine\n 1981 03:09:28,790 --> 03:09:37,310 say three note for the RPM, let's say 8000.\n 1982 03:09:37,309 --> 03:09:42,340 pass it to the constructor of our car for\n 1983 03:09:42,340 --> 03:09:48,969 that we can create our car but the other way\n 1984 03:09:48,969 --> 03:09:54,299 of your car. For example, I can see a new\n 1985 03:09:54,299 --> 03:10:02,109 engine objects directly inside the constructor.\n 1986 03:10:02,110 --> 03:10:06,900 we have passed it directly, we don't need\n 1987 03:10:06,899 --> 03:10:12,728 we don't use Renault engine, but I think it\n 1988 03:10:12,728 --> 03:10:18,300 our car objects, we can have access to all\n 1989 03:10:18,300 --> 03:10:22,920 if you want to print the name of our car,\n 1990 03:10:22,920 --> 03:10:30,299 Mercedes dot name, or that gets named to riversides.\n 1991 03:10:30,299 --> 03:10:36,029 engine of this car? Well, for that, we can\n 1992 03:10:36,030 --> 03:10:40,659 model. Plus, we can say Mercedes dot 1993 03:10:40,659 --> 03:10:46,579 get engine, this method in here. After that,\n 1994 03:10:46,579 --> 03:10:52,789 get engine method will return an engine object\n 1995 03:10:52,790 --> 03:10:57,540 on that, let's run the application and see\n 1996 03:10:57,540 --> 03:11:03,011 can see the name of our car, and after that,\n 1997 03:11:03,011 --> 03:11:08,550 Also instead of using the methods of your\n 1998 03:11:08,549 --> 03:11:15,049 For example, in here before the printer statement,\n 1999 03:11:15,049 --> 03:11:21,659 is equal to let's say Mercedes dot get engine.\n 2000 03:11:21,659 --> 03:11:27,110 you are not sure about the return type, you\n 2001 03:11:27,110 --> 03:11:31,610 over in your method, you can see the return\n 2002 03:11:31,610 --> 03:11:36,630 method which says public engine get engine,\n 2003 03:11:36,629 --> 03:11:42,920 an engine object. Now that you have your instance\n 2004 03:11:42,920 --> 03:11:48,390 on that, instead of pressing down the control\n 2005 03:11:48,390 --> 03:11:53,719 option to get the return type and for that\n 2006 03:11:53,719 --> 03:11:57,909 here is how you can do that, you can click\n 2007 03:11:57,909 --> 03:12:03,110 down the control key. This way, you can see\n 2008 03:12:03,110 --> 03:12:08,329 your method. These kinds of documentation\n 2009 03:12:08,329 --> 03:12:13,979 a third party library or some built in methods.\n 2010 03:12:13,979 --> 03:12:20,149 method and press Ctrl Q, you can see that\n 2011 03:12:20,149 --> 03:12:25,159 For example, in this case, it says that this\n 2012 03:12:25,159 --> 03:12:30,350 the line, you can see some information about\n 2013 03:12:30,350 --> 03:12:35,659 can have this kind of information on the methods\n 2014 03:12:35,659 --> 03:12:41,810 this get engine method. If we switch to our\n 2015 03:12:41,810 --> 03:12:46,799 Let's find that method. And here is how you\n 2016 03:12:46,799 --> 03:12:51,769 In previous videos, we have seen how to create\n 2017 03:12:51,770 --> 03:12:57,229 have create our comment. But these kinds of\n 2018 03:12:57,229 --> 03:13:03,319 we can use a single slash. And after that,\n 2019 03:13:03,319 --> 03:13:08,549 You can see that we have these sorts of comments\n 2020 03:13:08,549 --> 03:13:14,409 for when you have multiple lines. And in here\n 2021 03:13:14,409 --> 03:13:20,239 later on will be shown when you press Ctrl\n 2022 03:13:20,239 --> 03:13:27,021 in here, let's say returns the engine of our\n 2023 03:13:27,021 --> 03:13:32,640 in here, if we switch back to our main class\n 2024 03:13:32,639 --> 03:13:38,379 if we press Ctrl plus Q, you can see that\n 2025 03:13:38,379 --> 03:13:42,979 these kinds of commenting can be useful as\n 2026 03:13:42,979 --> 03:13:48,109 comments. For example, we can provide some\n 2027 03:13:48,110 --> 03:13:54,850 videos. So this way of using different classes\n 2028 03:13:54,850 --> 03:13:59,819 in object oriented programming. Once again,\n 2029 03:13:59,819 --> 03:14:05,319 example, a stereo system class and also a\n 2030 03:14:05,319 --> 03:14:09,970 one by one in here as well. But for the sake\n 2031 03:14:09,970 --> 03:14:15,399 this way we can compose different objects\n 2032 03:14:15,399 --> 03:14:20,859 talking about composition. Let's talk about\n 2033 03:14:20,860 --> 03:14:26,640 let's close this car class. And let's comment\n 2034 03:14:26,639 --> 03:14:32,520 times that you don't want to instantiate your\n 2035 03:14:32,521 --> 03:14:40,220 here I can say car Mercedes is equal to I\n 2036 03:14:40,219 --> 03:14:45,639 here like we did before. Instead, I want to\n 2037 03:14:45,639 --> 03:14:52,279 that you can pass null values for your objects.\n 2038 03:14:52,280 --> 03:14:58,590 in Java means nothing. It means that this\n 2039 03:14:58,590 --> 03:15:04,610 an object is now You cannot perform any kind\n 2040 03:15:04,610 --> 03:15:10,960 I cannot say Mercedes dot get name, for example,\n 2041 03:15:10,959 --> 03:15:16,140 means that our application is going to be\n 2042 03:15:16,140 --> 03:15:21,859 here, it says that this method is going to\n 2043 03:15:21,860 --> 03:15:27,220 from previous videos, I said that whenever\n 2044 03:15:27,219 --> 03:15:32,739 is going to crash. So the error in here is\n 2045 03:15:32,739 --> 03:15:37,530 time error. Let's run our application. And\n 2046 03:15:37,530 --> 03:15:42,900 in here we are getting a red warning in our\n 2047 03:15:42,899 --> 03:15:48,850 In general, we should always avoid exceptions\n 2048 03:15:48,850 --> 03:15:54,329 about how can we do that, but for now, let's\n 2049 03:15:54,329 --> 03:15:59,930 is now we cannot perform any operation on\n 2050 03:15:59,930 --> 03:16:05,511 inside that object. So whenever you're not\n 2051 03:16:05,511 --> 03:16:10,950 you are retrieving some data from a web server,\n 2052 03:16:10,950 --> 03:16:16,261 you need to check that if your object is null\n 2053 03:16:16,261 --> 03:16:22,200 example, you can create an if statement before\n 2054 03:16:23,771 --> 03:16:30,590 is not equal to Now, I'm going to put an if\n 2055 03:16:30,590 --> 03:16:36,870 now we are going to call this method but in\n 2056 03:16:36,870 --> 03:16:42,110 Let's say the car was now let's run the application\n 2057 03:16:42,110 --> 03:16:47,200 are not seeing the exception, which is good.\n 2058 03:16:47,200 --> 03:16:53,370 With our value being now we are just printing\n 2059 03:16:53,370 --> 03:16:58,910 But sometimes you may want to check that what\n 2060 03:16:58,909 --> 03:17:05,399 not means nothing in Java? Okay, let's comment\n 2061 03:17:05,399 --> 03:17:11,959 keyword in Java called final. So up to this\n 2062 03:17:11,959 --> 03:17:17,019 or variable, because I've said something like\n 2063 03:17:17,020 --> 03:17:22,510 For example, later on, we could have changed\n 2064 03:17:22,510 --> 03:17:29,059 is equal to five plus five for a plus fun.\n 2065 03:17:29,059 --> 03:17:34,170 of our variable. But there are some times\n 2066 03:17:34,170 --> 03:17:39,260 your variable wouldn't change. In those cases,\n 2067 03:17:39,260 --> 03:17:44,590 how you can do that before the type of your\n 2068 03:17:44,590 --> 03:17:50,069 equal to five. Now if I try to change the\n 2069 03:17:50,069 --> 03:17:55,379 if I say a is equal to a plus one, you can\n 2070 03:17:55,379 --> 03:18:01,369 the warning says that cannot assign a value\n 2071 03:18:01,370 --> 03:18:07,670 your variables and classes as final, you cannot\n 2072 03:18:07,670 --> 03:18:12,760 Let's also check the case when we define our\n 2073 03:18:12,760 --> 03:18:18,840 two line of code. And then in here, I'm going\n 2074 03:18:18,840 --> 03:18:27,189 it engine is equal to new engine. Let's pass\n 2075 03:18:27,189 --> 03:18:33,941 value of this engine, for example, if I say\n 2076 03:18:33,941 --> 03:18:40,560 parameters, for example, let's change the\n 2077 03:18:40,559 --> 03:18:46,069 the error, the error says that cannot assign\n 2078 03:18:46,069 --> 03:18:52,039 point in here. When you declare your objects\n 2079 03:18:52,040 --> 03:18:58,280 of that object. But you can change the properties\n 2080 03:18:58,280 --> 03:19:02,890 remember, inside our engine class, we had\n 2081 03:19:02,889 --> 03:19:07,789 them, we could have changed the value of two\n 2082 03:19:07,790 --> 03:19:15,110 the RPM, because I said something like engine\n 2083 03:19:15,110 --> 03:19:21,260 that even though we declared our engine as\n 2084 03:19:21,260 --> 03:19:27,069 cannot change the whole instance we can change\n 2085 03:19:27,069 --> 03:19:31,449 useful from time to time. Okay, I think that's\n 2086 03:19:31,450 --> 03:19:36,540 we are going to have a quick challenge to\n 2087 03:19:36,540 --> 03:19:46,881 of object oriented programming. See you in\n 2088 03:19:46,880 --> 03:19:51,930 that you are a doctor and you want to check\n 2089 03:19:51,930 --> 03:19:57,620 of all, you're showing the name and age of\n 2090 03:19:57,620 --> 03:20:02,850 can see a list of different organs in which\n 2091 03:20:02,850 --> 03:20:08,750 eye. Let's select that. In here, you can see\n 2092 03:20:08,750 --> 03:20:13,889 organ, for example, the name, the medical\n 2093 03:20:13,889 --> 03:20:19,430 After that, we gave the doctor the option\n 2094 03:20:19,430 --> 03:20:24,350 we are going to open that let's select one\n 2095 03:20:24,350 --> 03:20:29,829 left eye closed. Once again, we are seeing\n 2096 03:20:29,829 --> 03:20:36,389 in this case. This time, if I don't want to\n 2097 03:20:36,389 --> 03:20:41,529 beside one for example, if I put two in here,\n 2098 03:20:41,530 --> 03:20:47,770 the list of different organs. Let's select\n 2099 03:20:47,770 --> 03:20:52,090 see that we are seeing some details about\n 2100 03:20:52,090 --> 03:20:57,978 to change the heart rate. In a normal doctor\n 2101 03:20:57,978 --> 03:21:05,379 option. But in here, we just want to demonstrate\n 2102 03:21:05,379 --> 03:21:13,149 select Vani, here, the scanner is asking for\n 2103 03:21:13,149 --> 03:21:15,969 you can see that heart rate change to 75. 2104 03:21:15,969 --> 03:21:22,728 Let's select a stomach. Once again, you can\n 2105 03:21:22,728 --> 03:21:28,979 behavior in here, which is digest. If we select\n 2106 03:21:28,979 --> 03:21:34,719 Once again, this is a hypothetical situation.\n 2107 03:21:34,719 --> 03:21:41,649 the patient to digest the food. Let's also\n 2108 03:21:41,649 --> 03:21:46,600 time for the skin, you can see that we are\n 2109 03:21:46,600 --> 03:21:53,649 seeing some details. After that, once again,\n 2110 03:21:53,649 --> 03:21:58,890 for that matter any other number, we will\n 2111 03:21:58,890 --> 03:22:04,779 And as you can see application has been exited\n 2112 03:22:04,780 --> 03:22:10,460 want you to practice the object oriented programming\n 2113 03:22:10,459 --> 03:22:16,589 past three videos. So make sure to use them.\n 2114 03:22:16,590 --> 03:22:21,290 the challenge. After that, come back to the\n 2115 03:22:21,290 --> 03:22:28,890 as well. Here is my solution for the challenge.\n 2116 03:22:28,889 --> 03:22:39,909 inside my source folder. Let's name it or\n 2117 03:22:39,909 --> 03:22:49,250 I am going to create my organ class. Inside\n 2118 03:22:49,250 --> 03:22:57,879 let's say private string, name and also private\n 2119 03:22:57,879 --> 03:23:04,769 it simple. So I think these two would be fine.\n 2120 03:23:04,770 --> 03:23:09,620 And after that, let's create all of the getters\n 2121 03:23:09,620 --> 03:23:14,870 to use all of these getters and setters. later\n 2122 03:23:14,870 --> 03:23:20,810 delete them. Beside these, I'm going to have\n 2123 03:23:20,809 --> 03:23:31,590 details. Let's see that as well. Let's say\n 2124 03:23:31,590 --> 03:23:42,110 some details about this Oregon. First of all,\n 2125 03:23:42,110 --> 03:23:51,720 After that, let's print a medical condition\n 2126 03:23:51,719 --> 03:23:58,489 these that get medical condition. That's all\n 2127 03:23:58,489 --> 03:24:06,260 create our organs one by one. First of all,\n 2128 03:24:06,260 --> 03:24:14,770 say I inside this iclass I'm going to have\n 2129 03:24:14,770 --> 03:24:24,750 have a Boolean indicating if the eye is open\n 2130 03:24:24,750 --> 03:24:31,680 After that, it's time to extend the Oregon\n 2131 03:24:31,680 --> 03:24:37,430 are using inheritance. Now it's the time to\n 2132 03:24:37,430 --> 03:24:42,630 of these two fields. And after that, let's\n 2133 03:24:42,630 --> 03:24:47,630 again, I'm not sure that we are going to use\n 2134 03:24:47,630 --> 03:24:53,149 If we didn't use them, we just simply delete\n 2135 03:24:53,149 --> 03:24:59,680 method. I can do that by pressing Ctrl plus\n 2136 03:24:59,680 --> 03:25:04,690 can change Use this method. For example, in\n 2137 03:25:04,690 --> 03:25:15,980 eye. Let's say color. Plus this dot get color.\n 2138 03:25:15,979 --> 03:25:25,289 other methods as well, let's see them, let's\n 2139 03:25:25,290 --> 03:25:32,220 I'm going to change the value of this Boolean\n 2140 03:25:32,219 --> 03:25:37,569 And let's fast through. After that, let's\n 2141 03:25:37,569 --> 03:25:45,799 opened. Let's say this that gets name, you\n 2142 03:25:45,799 --> 03:25:50,769 Inside this class, we are using the getname\n 2143 03:25:50,770 --> 03:25:59,739 say plus opened. Let's have another method\n 2144 03:25:59,739 --> 03:26:06,840 close. Once again, first of all, I'm going\n 2145 03:26:06,840 --> 03:26:13,880 Let's say this dot set opened, and let's pass\n 2146 03:26:13,879 --> 03:26:16,478 Let's say this dot get name 2147 03:26:16,478 --> 03:26:23,140 plus close. That's all we need inside this\n 2148 03:26:23,140 --> 03:26:32,209 for the heart. Let's say heart. For this heart\n 2149 03:26:32,209 --> 03:26:42,728 rate, let's say private int rate. It's time\n 2150 03:26:42,728 --> 03:26:49,739 And after that, we need to create our constructor.\n 2151 03:26:49,739 --> 03:26:55,319 and setters. I'm pressing ALT plus insert\n 2152 03:26:55,319 --> 03:27:01,649 for you. After that, it's time to override\n 2153 03:27:01,649 --> 03:27:07,699 Oh, and by selecting get details method, we\n 2154 03:27:07,700 --> 03:27:18,729 the heart rate, let's say heart rate. Plus\n 2155 03:27:18,728 --> 03:27:24,840 all we need to do inside this heart class.\n 2156 03:27:24,840 --> 03:27:32,149 say stomache. Inside this Islamic class, I'm\n 2157 03:27:32,149 --> 03:27:39,869 these empty indicating if the Islamic is empty\n 2158 03:27:39,870 --> 03:27:49,010 Oregon class extends Oregon. And after that,\n 2159 03:27:49,010 --> 03:27:55,690 our getters and setters. And after that, let's\n 2160 03:27:55,690 --> 03:28:00,569 get details method. First of all, I'm going\n 2161 03:28:00,569 --> 03:28:07,949 So let's say if this.is empty, I'm going to\n 2162 03:28:07,950 --> 03:28:16,979 empty, I'm going to print something I'm going\n 2163 03:28:16,978 --> 03:28:24,269 let's just print the stomach is full. Let's\n 2164 03:28:24,270 --> 03:28:34,290 called digest. Let's say public void digest.\n 2165 03:28:34,290 --> 03:28:41,280 begin. Okay, we are done with our stomach\n 2166 03:28:41,280 --> 03:28:48,960 as well. For this Scan Class, I'm going to\n 2167 03:28:48,959 --> 03:28:56,309 going to define a string for the color of\n 2168 03:28:56,309 --> 03:29:03,930 an integer for the softness of their skin,\n 2169 03:29:03,930 --> 03:29:10,180 is going to be some number from zero to 100,\n 2170 03:29:10,180 --> 03:29:18,139 that it's time to extend the organic class.\n 2171 03:29:18,139 --> 03:29:25,279 Next, we need to create our getters and setters.\n 2172 03:29:25,280 --> 03:29:35,650 method. Inside this method, let's also print\n 2173 03:29:35,649 --> 03:29:43,279 dot get color. That's all of our organs. Now\n 2174 03:29:43,280 --> 03:29:49,909 package. Let's create a patient class. For\n 2175 03:29:49,909 --> 03:29:55,629 a string for its name. After that, we are\n 2176 03:29:55,629 --> 03:30:02,779 patient. After that we can create our organs.\n 2177 03:30:02,780 --> 03:30:15,141 let's say left eye. Let's do the same for\n 2178 03:30:15,140 --> 03:30:25,329 that may be a stomach and a skin. Okay, that's\n 2179 03:30:28,170 --> 03:30:36,610 And let's create all of the getters and setters.\n 2180 03:30:36,610 --> 03:30:43,170 patient class, inside our main class, which\n 2181 03:30:43,170 --> 03:30:49,280 Let's create our main class. First of all\n 2182 03:30:49,280 --> 03:30:53,530 After that, we can create our patient object.\n 2183 03:30:53,530 --> 03:31:01,181 main. Let's say patient, let's name the patient\n 2184 03:31:01,181 --> 03:31:07,890 need a naming here, let's say Brad. After\n 2185 03:31:07,889 --> 03:31:14,129 that, we need the left eye which I can say\n 2186 03:31:14,129 --> 03:31:20,359 name, let's say left eye. After that, we need\n 2187 03:31:20,360 --> 03:31:30,150 say short sighted. For the color, let's say\n 2188 03:31:30,149 --> 03:31:41,069 we need the same thing for the right I knew\n 2189 03:31:41,069 --> 03:31:50,889 let's change the medical condition to normal.\n 2190 03:31:50,889 --> 03:31:59,320 heart. For the medical condition, let's say\n 2191 03:31:59,320 --> 03:32:08,280 just say 65. I think the next organ was a\n 2192 03:32:08,280 --> 03:32:13,721 would be Islamic. The medical condition, I'm\n 2193 03:32:13,720 --> 03:32:20,689 condition, I'm going to say p UD public services\n 2194 03:32:20,690 --> 03:32:27,250 empty, let's say false. After that, we need\n 2195 03:32:27,250 --> 03:32:33,851 their skin. Or First of all, we need the name,\n 2196 03:32:33,851 --> 03:32:41,220 let's say burnt. After that, what do we need,\n 2197 03:32:41,219 --> 03:32:48,569 color, let's say right? For the softness,\n 2198 03:32:48,569 --> 03:32:54,000 patient object. Now we need to create the\n 2199 03:32:54,000 --> 03:33:02,420 going to print the name and age of the patient.\n 2200 03:33:02,420 --> 03:33:12,860 gets me after that do the same thing for the\n 2201 03:33:12,860 --> 03:33:19,650 So we need a scanner. Let's say a scanner\n 2202 03:33:19,649 --> 03:33:26,649 system that. Also, now that we know about\n 2203 03:33:26,649 --> 03:33:31,279 scanner is working. This is just the class\n 2204 03:33:31,280 --> 03:33:36,940 it inside the constructor of this scanner,\n 2205 03:33:36,940 --> 03:33:43,190 this way we have created an instance of this\n 2206 03:33:43,190 --> 03:33:49,520 Boolean, let's say Boolean. Let's name it\n 2207 03:33:49,520 --> 03:33:55,110 it to false. Later on, we will see that how\n 2208 03:33:55,110 --> 03:34:01,350 I'm going to create a while loop let's say\n 2209 03:34:01,350 --> 03:34:07,110 continue looping. Inside the while loop, I'm\n 2210 03:34:07,110 --> 03:34:15,740 For that I can say choose an organ. In here\n 2211 03:34:15,740 --> 03:34:22,329 dot out dot print lines line after line. Or\n 2212 03:34:22,329 --> 03:34:28,228 see that as well. First of all, let's go to\n 2213 03:34:28,228 --> 03:34:34,399 In here I can say backslash n, this backslash\n 2214 03:34:34,399 --> 03:34:40,629 one that I'm going to use in here is called\n 2215 03:34:40,629 --> 03:34:46,099 to our text. Later on we will see exactly\n 2216 03:34:49,689 --> 03:35:03,220 The next one is right I \n 2217 03:35:03,219 --> 03:35:09,840 to receive the user's input. So I'm going\n 2218 03:35:09,840 --> 03:35:15,560 next int. We have seen this in previous videos.\n 2219 03:35:15,560 --> 03:35:20,978 just going to receive the user's input. After\n 2220 03:35:20,978 --> 03:35:26,609 to create a switch statement, let's say switch\n 2221 03:35:26,610 --> 03:35:33,229 cases. In case the user's choice is one, first\n 2222 03:35:33,228 --> 03:35:42,019 about the left eye. So let's say patient that\n 2223 03:35:42,020 --> 03:35:47,229 to give the user the option to open or close\n 2224 03:35:47,228 --> 03:35:54,459 the eye is opened or closed. So let's say\n 2225 03:35:54,459 --> 03:36:00,319 we need to close it, or at least we need to\n 2226 03:36:00,319 --> 03:36:06,760 in here. Let's say backslash, D, backslash\n 2227 03:36:06,760 --> 03:36:15,970 say close or close the next we need to get\n 2228 03:36:15,970 --> 03:36:26,081 going to close the eyes. So let's say if a\n 2229 03:36:26,081 --> 03:36:34,180 we need to say patient dot get left eye dot,\n 2230 03:36:34,180 --> 03:36:40,130 we are just going to continue to the next\n 2231 03:36:40,129 --> 03:36:45,789 this finding here in case the eye is not opened,\n 2232 03:36:45,790 --> 03:36:52,610 eyes. So let's say else, we need the same\n 2233 03:36:52,610 --> 03:37:02,010 backslash t Vaughn opened it. Next, we need\n 2234 03:37:02,010 --> 03:37:11,989 dot next int is equal to one, we are going\n 2235 03:37:11,989 --> 03:37:17,860 In the else case, we are just going to continue.\n 2236 03:37:17,860 --> 03:37:23,650 to show the list of different organs. Okay,\n 2237 03:37:23,649 --> 03:37:30,879 in here. But let's write the second case.\n 2238 03:37:30,879 --> 03:37:38,369 can copy and paste all of these logic. But\n 2239 03:37:38,370 --> 03:37:49,211 So for example, in here, let's say get right.\n 2240 03:37:49,210 --> 03:37:55,549 also write the case for the heart. Let's say\n 2241 03:37:55,549 --> 03:38:04,739 of the heart, let's say patient that get heart\n 2242 03:38:04,739 --> 03:38:10,659 to give the user to change the heart rate.\n 2243 03:38:10,659 --> 03:38:17,590 T one, change the heart rate. Once again,\n 2244 03:38:17,590 --> 03:38:26,049 let's say if the scanner dot next int is equal\n 2245 03:38:26,049 --> 03:38:31,389 So let's say enter a new heart rate. After\n 2246 03:38:31,389 --> 03:38:40,279 let's say int is equal to a scanner dot next.\n 2247 03:38:40,280 --> 03:38:47,070 dot, let's say set rate. And let's pass our\n 2248 03:38:47,069 --> 03:38:52,920 before, we are going to continue. We also\n 2249 03:38:52,920 --> 03:38:59,689 and also after changing the heart rate, it's\n 2250 03:38:59,689 --> 03:39:12,610 rate change to plus patients that get heart\n 2251 03:39:12,610 --> 03:39:17,960 The fourth one was for the stomach. So let's\n 2252 03:39:17,959 --> 03:39:25,819 the details of the stomach patients that get\n 2253 03:39:25,819 --> 03:39:32,100 we had the digest option. So in here, let's\n 2254 03:39:32,100 --> 03:39:41,220 Let's see digest. Let's see if the scanner\n 2255 03:39:41,219 --> 03:39:49,359 If that's the case, let's say patient dot\n 2256 03:39:49,360 --> 03:39:55,750 let's just continue. We also need a break\n 2257 03:39:55,750 --> 03:40:02,989 case is for the scheme. Let's say case five\n 2258 03:40:02,989 --> 03:40:10,670 we just need to print the details, let's say\n 2259 03:40:10,670 --> 03:40:16,021 course after that we need to add a break.\n 2260 03:40:16,021 --> 03:40:21,950 And if the user enters any other number than\n 2261 03:40:21,950 --> 03:40:27,840 For that we are going to change the value\n 2262 03:40:27,840 --> 03:40:36,260 that, we need a break. Okay, I think our application\n 2263 03:40:36,260 --> 03:40:41,719 In here, we can see the name and age of the\n 2264 03:40:41,719 --> 03:40:48,319 list of our organs. Once again, it's good.\n 2265 03:40:48,319 --> 03:40:54,129 of the left eye. And also we have this close\n 2266 03:40:54,129 --> 03:41:00,889 this one, let's say to once again, we can\n 2267 03:41:00,889 --> 03:41:06,469 can close the left eye. Let's put one in here.\n 2268 03:41:06,469 --> 03:41:12,520 closed. Okay, let's check the right eye. It's\n 2269 03:41:12,521 --> 03:41:18,560 in order to show the list of organs. And let's\n 2270 03:41:18,559 --> 03:41:24,129 which is good. Let's see if we can change\n 2271 03:41:24,129 --> 03:41:30,179 the console is waiting for the new heart rates,\n 2272 03:41:30,180 --> 03:41:35,350 has been changed to 75. Let's check it once\n 2273 03:41:35,350 --> 03:41:41,351 say three. And as you can see, the heart rate\n 2274 03:41:41,351 --> 03:41:47,230 of organs. And let's select four in order\n 2275 03:41:47,229 --> 03:41:54,140 details of the stomach. Let's digest some\n 2276 03:41:54,140 --> 03:41:59,389 Let's check the skin which is five, you can\n 2277 03:41:59,389 --> 03:42:05,189 skin. But we don't have any option. That seems\n 2278 03:42:05,189 --> 03:42:10,659 then these five we should create the application.\n 2279 03:42:10,659 --> 03:42:16,059 as you can see application has been finished\n 2280 03:42:16,059 --> 03:42:22,350 is working fine. Let's just delete the getter\n 2281 03:42:22,350 --> 03:42:27,670 delete if we didn't use them. Let's check\n 2282 03:42:27,670 --> 03:42:33,379 the iclass. Everything that is grayed out\n 2283 03:42:33,379 --> 03:42:39,069 we never used this set color method. Okay,\n 2284 03:42:39,069 --> 03:42:47,459 I think we have used all of them. Okay, that's\n 2285 03:42:47,459 --> 03:42:53,549 this set medical condition method. And also\n 2286 03:42:53,549 --> 03:43:00,349 the patient class. Let's see what do we have\n 2287 03:43:00,350 --> 03:43:13,430 the setters of this patient class. Let's just\n 2288 03:43:13,430 --> 03:43:18,689 Let's see, what do you have inside a scheme\n 2289 03:43:18,689 --> 03:43:24,939 and this get softness method. Let's delete\n 2290 03:43:24,939 --> 03:43:30,479 this set empty method. And in order to make\n 2291 03:43:30,478 --> 03:43:36,899 one more time. Okay, it seems like we don't\n 2292 03:43:36,899 --> 03:43:42,420 be fine. Okay, that was our challenge about\n 2293 03:43:42,420 --> 03:43:46,340 upload the source code at the links that you\n 2294 03:43:46,340 --> 03:43:51,350 them and also, I'm more than happy to see\n 2295 03:43:51,350 --> 03:44:01,530 video, we will talk about collections in Java.\n 2296 03:44:01,530 --> 03:44:06,771 we have seen simple arrays in Java. For example,\n 2297 03:44:06,771 --> 03:44:11,970 names, we could have said something like this\n 2298 03:44:11,969 --> 03:44:16,739 square bracket. After that, we could have\n 2299 03:44:16,739 --> 03:44:22,149 initialized our string array like this inside\n 2300 03:44:22,149 --> 03:44:27,439 the size of our array for example five. The\n 2301 03:44:27,439 --> 03:44:32,500 time of instantiating our array for example,\n 2302 03:44:32,500 --> 03:44:37,069 and inside those curly braces because I've\n 2303 03:44:39,030 --> 03:44:43,130 After that, if we wanted to have access to\n 2304 03:44:43,129 --> 03:44:49,770 like this, we could have said print, let's\n 2305 03:44:49,771 --> 03:44:54,450 the third element, which is Brad in this case,\n 2306 03:44:54,450 --> 03:45:00,101 should see Brad. Let's run it. You can see\n 2307 03:45:00,101 --> 03:45:06,310 I said that using these kinds of simple arrays\n 2308 03:45:06,309 --> 03:45:11,799 the first limitation is that their size is\n 2309 03:45:11,799 --> 03:45:17,429 be changed. Right now we have five elements\n 2310 03:45:17,430 --> 03:45:21,898 another item inside this array, we cannot\n 2311 03:45:21,898 --> 03:45:28,029 like names with an index of five, which indicates\n 2312 03:45:28,030 --> 03:45:33,790 to that, you can see that in here we have\n 2313 03:45:33,790 --> 03:45:39,870 we get an exception. Let's see the exception.\n 2314 03:45:39,870 --> 03:45:44,640 bounds exception. Also, when working with\n 2315 03:45:44,639 --> 03:45:49,319 much options. Later on, we will see that when\n 2316 03:45:49,319 --> 03:45:54,739 can operate all sorts of operations on our\n 2317 03:45:54,739 --> 03:46:01,149 simple areas. If we want to add a sixth element\n 2318 03:46:01,149 --> 03:46:06,409 after that, we can copy all of the elements\n 2319 03:46:06,409 --> 03:46:12,170 situation that we have in here. If we want\n 2320 03:46:12,170 --> 03:46:16,940 another array with the size of six. After\n 2321 03:46:16,940 --> 03:46:22,500 that array. And after everything, we can add\n 2322 03:46:22,500 --> 03:46:29,440 say a string array. Let's name it new names,\n 2323 03:46:29,440 --> 03:46:35,860 of six. After that I can create a for loop\n 2324 03:46:35,860 --> 03:46:41,930 than names dot length, and i plus plus. And\n 2325 03:46:41,930 --> 03:46:47,930 to add all of the names to this new names\n 2326 03:46:47,930 --> 03:46:53,680 i is equal to names with an index of oil.\n 2327 03:46:53,680 --> 03:46:59,389 from inside this names array to this new names\n 2328 03:46:59,389 --> 03:47:06,939 After the for loop, I can say new names with\n 2329 03:47:06,940 --> 03:47:12,319 we can get around this problem. For example,\n 2330 03:47:12,319 --> 03:47:19,029 maybe after that, print the six element inside\n 2331 03:47:19,030 --> 03:47:24,510 you can see, this solution is not that much\n 2332 03:47:24,510 --> 03:47:29,340 see Jerry has been printed in here. But as\n 2333 03:47:29,340 --> 03:47:35,409 And beside that if your array has a lot of\n 2334 03:47:35,409 --> 03:47:40,469 this process can be really time consuming.\n 2335 03:47:40,469 --> 03:47:45,879 if you are downloading this array from the\n 2336 03:47:45,879 --> 03:47:51,849 effective. Instead of copy and pasting the\n 2337 03:47:51,850 --> 03:47:56,409 Let's delete all of these codes. In Java,\n 2338 03:47:56,409 --> 03:48:00,659 first of which I'm going to talk about in\n 2339 03:48:00,659 --> 03:48:08,329 that so we type array list with capsule a.\n 2340 03:48:08,329 --> 03:48:14,090 or as some might call them diamonds, we need\n 2341 03:48:14,090 --> 03:48:19,120 for example, I can say is string. After that\n 2342 03:48:19,120 --> 03:48:25,579 I can say names, is equal to new ArrayList.\n 2343 03:48:25,579 --> 03:48:30,389 is one way of defining your ArrayList. There\n 2344 03:48:30,389 --> 03:48:35,650 so instead of saying ArrayList string, we\n 2345 03:48:35,650 --> 03:48:40,869 here is different. It's an interface. We will\n 2346 03:48:40,870 --> 03:48:45,380 But for now just know that there are two ways\n 2347 03:48:45,379 --> 03:48:52,090 can we use this list to create an ArrayList\n 2348 03:48:52,091 --> 03:48:58,960 again, let's name our list. For example, let's\n 2349 03:48:58,959 --> 03:49:03,750 is a slight difference in here. But I just\n 2350 03:49:03,750 --> 03:49:09,299 ArrayList. Okay, let's delete this line for\n 2351 03:49:09,299 --> 03:49:14,340 if we want to add some elements to this ArrayList,\n 2352 03:49:14,340 --> 03:49:19,680 we can use this add method in order to add\n 2353 03:49:19,680 --> 03:49:24,989 let's add one. You can use this add method\n 2354 03:49:24,989 --> 03:49:31,728 another element, I can simply do that. So\n 2355 03:49:31,728 --> 03:49:37,959 Now the size of array list is mutable, it\n 2356 03:49:37,959 --> 03:49:43,179 list. After adding some elements to your array\n 2357 03:49:43,180 --> 03:49:48,809 the get method. Let's quickly say that, for\n 2358 03:49:48,809 --> 03:49:55,369 see names that get you can see that this get\n 2359 03:49:55,370 --> 03:50:01,270 in Java start from zero so if I pass zero\n 2360 03:50:01,270 --> 03:50:06,630 first element. Right now if I run my application,\n 2361 03:50:06,629 --> 03:50:11,709 you can see that Mason has been printed. Also\n 2362 03:50:11,709 --> 03:50:16,350 size of your array list. For example, if I\n 2363 03:50:16,351 --> 03:50:21,950 can say something like this, I can say names\n 2364 03:50:21,950 --> 03:50:26,740 what would be the result, you can see that\n 2365 03:50:26,739 --> 03:50:32,610 all sorts of options when using array lists,\n 2366 03:50:32,610 --> 03:50:39,079 your ArrayList. For example, I can say names\n 2367 03:50:39,079 --> 03:50:44,228 the elements inside your ArrayList. After\n 2368 03:50:44,228 --> 03:50:49,688 my ArrayList this time the size should be\n 2369 03:50:49,689 --> 03:50:54,590 zero. If you want, you can also remove one\n 2370 03:50:54,590 --> 03:51:01,680 see that I can say names dot remove this remove\n 2371 03:51:01,680 --> 03:51:07,701 need to pass the whole element. So let's say\n 2372 03:51:07,700 --> 03:51:13,189 me quickly comment this line because we don't\n 2373 03:51:13,190 --> 03:51:21,100 my son, let's print the first element inside\n 2374 03:51:21,100 --> 03:51:26,250 let's pass zero as the index. As you can see,\n 2375 03:51:26,250 --> 03:51:30,940 that my Sam has been removed successfully.\n 2376 03:51:30,940 --> 03:51:36,860 our ArrayList. Let's like names by typing\n 2377 03:51:36,860 --> 03:51:42,600 also check that if an option exists in our\n 2378 03:51:42,600 --> 03:51:48,399 method, once again, it requires an object,\n 2379 03:51:48,398 --> 03:51:54,439 of code. This contains method returns a Boolean.\n 2380 03:51:54,439 --> 03:51:59,649 we have removed my sample we should see false,\n 2381 03:51:59,649 --> 03:52:06,430 this to Sarah, we should see through. And\n 2382 03:52:06,430 --> 03:52:13,271 ArrayList is empty or not. For that you can\n 2383 03:52:13,271 --> 03:52:19,510 empty, we have this method once again, it's\n 2384 03:52:19,510 --> 03:52:24,860 in our ArrayList. So it shouldn't be empty.\n 2385 03:52:24,860 --> 03:52:28,900 But if we remove Sara before this line of\n 2386 03:52:28,899 --> 03:52:36,289 do that names dot remove. And let's pass this\n 2387 03:52:36,290 --> 03:52:41,610 you can also get the index of some element\n 2388 03:52:41,610 --> 03:52:45,729 quickly see that before everything I'm going\n 2389 03:52:45,728 --> 03:52:48,920 I want to have a clear console. 2390 03:52:48,920 --> 03:52:56,770 down in here. Let's say print names that index\n 2391 03:52:56,770 --> 03:53:02,670 I can pass Mesa. Right now Mason is the first\n 2392 03:53:02,670 --> 03:53:08,430 can see that it's zero. But if we don't have\n 2393 03:53:08,430 --> 03:53:14,220 if we pass Brad in here, we should see negative\n 2394 03:53:14,219 --> 03:53:20,619 printed. When you're using ArrayList you can\n 2395 03:53:20,620 --> 03:53:26,240 inside your ArrayList. For example, in here,\n 2396 03:53:26,239 --> 03:53:32,060 data types when you are creating a new ArrayList.\n 2397 03:53:32,060 --> 03:53:37,510 says that type argument cannot be primitive\n 2398 03:53:37,510 --> 03:53:43,148 different numbers, you can use the equivalence\n 2399 03:53:43,148 --> 03:53:48,879 integer with a capital I. And now I have an\n 2400 03:53:48,879 --> 03:53:55,000 an error because I'm trying to add some strings\n 2401 03:53:55,000 --> 03:54:01,110 idea of we can use this integer class in order\n 2402 03:54:01,110 --> 03:54:06,541 to every primitive data type, you have a class\n 2403 03:54:06,540 --> 03:54:14,629 also check others, we can say Boolean similar\n 2404 03:54:14,629 --> 03:54:19,119 And you can check the others yourself. But\n 2405 03:54:19,120 --> 03:54:24,250 The other option that you have when you're\n 2406 03:54:24,250 --> 03:54:28,760 For example, if you want to sort different\n 2407 03:54:28,760 --> 03:54:34,110 you have that option. And the way to do that\n 2408 03:54:34,110 --> 03:54:40,670 we can see names that sort you can see that\n 2409 03:54:40,670 --> 03:54:45,680 later on in the course we will see this comparateur\n 2410 03:54:45,680 --> 03:54:50,780 to source different elements in our array\n 2411 03:54:50,780 --> 03:54:55,540 this I just wanted to say that you have this\n 2412 03:54:55,540 --> 03:55:00,030 move on from this part. Similar to simple\n 2413 03:55:00,030 --> 03:55:05,079 To read through all of the elements in your\n 2414 03:55:05,079 --> 03:55:12,510 see that as well. You can say for int i is\n 2415 03:55:12,510 --> 03:55:21,800 this time, i plus plus. Inside this for loop,\n 2416 03:55:21,799 --> 03:55:26,810 index of AI. This way, we can print all of\n 2417 03:55:26,810 --> 03:55:32,020 that, let's comment this line. And let's run\n 2418 03:55:32,021 --> 03:55:37,050 both of our elements printed. Okay, that's\n 2419 03:55:37,049 --> 03:55:42,829 talk about another kind of collection in Java\n 2420 03:55:42,829 --> 03:55:48,459 have some key value pair data. Let's define\n 2421 03:55:48,459 --> 03:55:53,429 key value pairs. You can define a map like\n 2422 03:55:53,430 --> 03:55:57,700 is an interface. We will talk about interfaces\n 2423 03:55:57,700 --> 03:56:02,829 video. But for now, let's move on. You can\n 2424 03:56:02,829 --> 03:56:08,459 inside these diamonds, we have these K and\n 2425 03:56:08,459 --> 03:56:13,439 in here, if we say anchor bracket, for the\n 2426 03:56:13,440 --> 03:56:19,079 key the data type of our keys. For example,\n 2427 03:56:19,079 --> 03:56:23,978 to provide the data type of our values. For\n 2428 03:56:23,978 --> 03:56:29,170 the data type of my values. Right now I'm\n 2429 03:56:29,170 --> 03:56:36,398 it seems like the ID hasn't imported maps\n 2430 03:56:36,398 --> 03:56:41,439 And if we take a look at above, in here, it\n 2431 03:56:41,439 --> 03:56:47,030 class successfully. After defining the data\n 2432 03:56:47,030 --> 03:56:54,189 you need to name your map. For example, I\n 2433 03:56:54,189 --> 03:56:58,380 But if I do that, you will see that there\n 2434 03:56:58,379 --> 03:57:04,559 about, there is a better way of defining your\n 2435 03:57:04,559 --> 03:57:11,719 the change, I can say new hashmap. This time,\n 2436 03:57:11,719 --> 03:57:16,799 And if you want we can instantiate our map\n 2437 03:57:16,799 --> 03:57:23,309 those extra methods. I don't intend to talk\n 2438 03:57:23,309 --> 03:57:28,489 technical, it's about the way that we are\n 2439 03:57:28,489 --> 03:57:33,149 It's way above the talk that we have in here,\n 2440 03:57:33,149 --> 03:57:38,629 your maps as different hash maps. Okay, now\n 2441 03:57:38,629 --> 03:57:44,339 of different keys is a string. And the data\n 2442 03:57:44,340 --> 03:57:49,390 If you want to put some elements to this map,\n 2443 03:57:49,390 --> 03:57:54,319 contacts that put this is the method that\n 2444 03:57:54,319 --> 03:57:59,270 to our map, you can see that right now this\n 2445 03:57:59,271 --> 03:58:06,239 a value for the key. For example, I can pass\n 2446 03:58:06,239 --> 03:58:13,171 let's pass his email, let's say me sam@maker.org.\n 2447 03:58:13,171 --> 03:58:18,250 think if I change the name of my contacts\n 2448 03:58:18,250 --> 03:58:23,809 much more better. In order to change the name\n 2449 03:58:23,809 --> 03:58:29,340 an option, you can select the whole name,\n 2450 03:58:29,340 --> 03:58:34,569 you can go to this refactor in here, and you\n 2451 03:58:34,569 --> 03:58:39,978 can use the shortcut, which is shift plus\n 2452 03:58:39,978 --> 03:58:43,819 to delete this whole name, you can see that\n 2453 03:58:43,819 --> 03:58:49,850 name in both places. So let's say email list.\n 2454 03:58:49,850 --> 03:58:56,280 much more suitable. Let's add another element\n 2455 03:58:56,280 --> 03:59:04,659 let's say Brad. And let's say brad@gmail.com.\n 2456 03:59:04,659 --> 03:59:09,860 I want to have access to those elements, I\n 2457 03:59:09,860 --> 03:59:15,500 let's print this statement. Let's say email\n 2458 03:59:15,500 --> 03:59:20,439 we have this get method which requires an\n 2459 03:59:20,439 --> 03:59:26,489 the key. For example, if I pass Mesa, as the\n 2460 03:59:26,489 --> 03:59:31,180 this case, I should see the email. Let's run\n 2461 03:59:31,180 --> 03:59:36,270 the email of maysa. You can see that the email\n 2462 03:59:36,270 --> 03:59:40,770 lists. When you are using maps, you have all\n 2463 03:59:40,770 --> 03:59:47,760 to get the size of your map, you can say something\n 2464 03:59:47,760 --> 03:59:52,320 Let's run the application and let's see if\n 2465 03:59:52,320 --> 03:59:58,840 want to remove an item from your map you can\n 2466 03:59:58,840 --> 04:00:04,690 remove required As an object, in this case,\n 2467 04:00:04,690 --> 04:00:10,149 And let's print the size of our map once again.\n 2468 04:00:10,149 --> 04:00:15,889 that the size is one. You can also check that\n 2469 04:00:15,889 --> 04:00:21,539 way to do that is like this. Let's bring that\n 2470 04:00:21,540 --> 04:00:27,460 contain keys. Similarly, we have contains\n 2471 04:00:27,459 --> 04:00:33,069 if some value exists in your map. Let's try\n 2472 04:00:33,069 --> 04:00:38,270 Brad in here, because we have removed breath,\n 2473 04:00:38,270 --> 04:00:43,430 false has been printed. But if I change this\n 2474 04:00:43,430 --> 04:00:48,130 seems to work fine. We can do the same thing\nfor the values. 2475 04:00:48,129 --> 04:00:56,819 Let's say email list dot contains value. Let's\n 2476 04:00:56,819 --> 04:01:02,189 Because it does exist in our map we should\n 2477 04:01:02,189 --> 04:01:08,200 other options. yourself. If you want. We can\n 2478 04:01:08,200 --> 04:01:13,409 that we have this clear option, it will clear\n 2479 04:01:13,409 --> 04:01:18,489 is empty method, it will check that if your\n 2480 04:01:18,489 --> 04:01:25,420 you have in here is this values, you can see\n 2481 04:01:25,420 --> 04:01:30,559 If you want to copy all of the values of your\n 2482 04:01:30,559 --> 04:01:35,739 save it inside a collection. But I'm not going\n 2483 04:01:35,739 --> 04:01:41,239 going to say that there is an interface in\n 2484 04:01:41,239 --> 04:01:46,969 which is the generic type of all of the collections\n 2485 04:01:46,969 --> 04:01:53,438 on when we source different items inside our\n 2486 04:01:53,439 --> 04:01:58,870 a primitive data type as the data type of\n 2487 04:01:58,870 --> 04:02:03,721 maps. For example, in here, I cannot say int\n 2488 04:02:03,720 --> 04:02:09,069 that type argument cannot be of primitive\n 2489 04:02:09,069 --> 04:02:15,149 say int, once again, you can use the equivalent\n 2490 04:02:15,149 --> 04:02:20,010 But you cannot just use primitive data types.\n 2491 04:02:20,010 --> 04:02:25,200 maps and array lists, you have other kinds\n 2492 04:02:25,200 --> 04:02:30,210 to talk about them in here, because I think\n 2493 04:02:30,209 --> 04:02:35,398 enough and you don't need to know about others.\n 2494 04:02:35,398 --> 04:02:41,069 this Oracle webpage, you can see that we have\n 2495 04:02:41,069 --> 04:02:46,478 But honestly, these are not going to be helpful\n 2496 04:02:46,478 --> 04:02:53,789 are just fine. As the data type of key values\n 2497 04:02:53,790 --> 04:02:59,189 You can also have different classes. Let's\n 2498 04:02:59,189 --> 04:03:03,750 inside the package, I'm going to create a\n 2499 04:03:03,750 --> 04:03:09,799 that inside this student class, I'm going\n 2500 04:03:09,799 --> 04:03:12,529 string name, and private integer 2501 04:03:14,021 --> 04:03:21,050 Let's have a constructor and some getters\n 2502 04:03:21,049 --> 04:03:26,688 class, I can pass it as the data type of my\n 2503 04:03:26,689 --> 04:03:32,860 list down in here. I can say ArrayList of\n 2504 04:03:32,860 --> 04:03:40,180 ArrayList students, let's say is equal to\n 2505 04:03:40,180 --> 04:03:48,079 as you want inside this ArrayList. For example,\n 2506 04:03:48,079 --> 04:03:53,643 student, let's say may sound with the idea\n 2507 04:03:53,643 --> 04:03:59,610 kind of customized datatype is agreeable with\n 2508 04:03:59,610 --> 04:04:04,319 I finish off this video I'm going to talk\n 2509 04:04:04,319 --> 04:04:09,148 when we talked about loops in Java, I said\n 2510 04:04:09,148 --> 04:04:14,309 for each loop, I said that we are going to\n 2511 04:04:14,309 --> 04:04:19,609 object oriented programming and also collections\n 2512 04:04:19,610 --> 04:04:24,400 talk about that you can create a for each\n 2513 04:04:24,399 --> 04:04:30,539 saying int i is equal to zero, I'm going to\n 2514 04:04:30,540 --> 04:04:35,620 to iterate over. For example, in this case,\n 2515 04:04:35,620 --> 04:04:41,570 a name. For example, I'm going to say s and\n 2516 04:04:41,569 --> 04:04:46,851 I need the list or ArrayList that I'm going\n 2517 04:04:46,851 --> 04:04:52,659 going to say students, let's review everything\n 2518 04:04:52,659 --> 04:04:57,530 passed the data type of the object that we\n 2519 04:04:57,530 --> 04:05:02,110 object is as you can name it, whatever Do\n 2520 04:05:02,110 --> 04:05:07,260 colon. And after that, you need to pass the\n 2521 04:05:07,260 --> 04:05:12,239 inside this for loop, you can use this s in\n 2522 04:05:12,239 --> 04:05:19,030 object. For example, if I want to print the\n 2523 04:05:19,030 --> 04:05:25,439 gets me right now our ArrayList has only one\n 2524 04:05:25,439 --> 04:05:33,819 say students that add a new student. Let's\n 2525 04:05:33,819 --> 04:05:38,180 run the application and see what would be\n 2526 04:05:38,180 --> 04:05:44,189 and Sarah has been preempted. So this is in\n 2527 04:05:44,189 --> 04:05:50,280 of being the index of the item, it's the item\n 2528 04:05:50,280 --> 04:05:54,610 be useful and this is how you can create them.\n 2529 04:05:54,610 --> 04:05:59,360 the video in here. In the next video we are\n 2530 04:05:59,360 --> 04:06:04,659 example, we will talk about this static keyword\n 2531 04:06:04,659 --> 04:06:09,610 main method. Besides that, if we had time,\n 2532 04:06:09,610 --> 04:06:18,840 talk about interfaces and abstract classes\n 2533 04:06:18,840 --> 04:06:24,239 we are going to talk about some small concepts\n 2534 04:06:24,239 --> 04:06:29,760 concepts is this static keyword that we have\n 2535 04:06:29,760 --> 04:06:34,489 method. I'm going to talk about that in another\n 2536 04:06:34,489 --> 04:06:41,930 package. Let's name this class test class.\n 2537 04:06:41,930 --> 04:06:46,989 can have this static keyword for our methods.\n 2538 04:06:46,989 --> 04:06:53,949 variables as a static as well. For example,\n 2539 04:06:53,950 --> 04:06:59,340 After that I can say a string. Let's say name,\n 2540 04:06:59,340 --> 04:07:04,760 I'm not sure if you have noticed or not. But\n 2541 04:07:04,760 --> 04:07:10,899 the style of this name has changed to italic.\n 2542 04:07:10,899 --> 04:07:16,059 But what does it mean to have a static variable\n 2543 04:07:16,059 --> 04:07:22,209 your variables and methods as static, those\n 2544 04:07:22,209 --> 04:07:27,659 itself and not to the instances of that object,\n 2545 04:07:27,659 --> 04:07:32,520 that, let's quickly have other variables in\n 2546 04:07:32,520 --> 04:07:41,420 int, age, maybe another one public, let's\n 2547 04:07:41,420 --> 04:07:46,270 doesn't mean anything, I just want to have\n 2548 04:07:46,270 --> 04:07:53,290 in here. Notice that when I use the intelligent\n 2549 04:07:53,290 --> 04:07:58,250 see my static variable in this list. Once\n 2550 04:07:58,250 --> 04:08:03,469 do not belong to the instances of the object\n 2551 04:08:03,469 --> 04:08:09,469 these two. And let's create getters and setters.\n 2552 04:08:09,469 --> 04:08:15,109 setter for this static variable. Okay, now\n 2553 04:08:15,110 --> 04:08:20,760 an instance of that class, for example, from\n 2554 04:08:20,760 --> 04:08:25,710 let's name it test class is equal to new test\n 2555 04:08:25,709 --> 04:08:32,769 for an age and also a skin color, let's say\n 2556 04:08:32,770 --> 04:08:38,470 of the class but how do we assign a value\n 2557 04:08:38,469 --> 04:08:44,329 class? Well, you can use the setter methods.\n 2558 04:08:44,329 --> 04:08:49,469 name, this method and you can pass a name\n 2559 04:08:49,469 --> 04:08:55,010 in here this highlighted warning. What does\n 2560 04:08:55,010 --> 04:09:00,659 this name variable even without instantiating\n 2561 04:09:00,659 --> 04:09:07,030 test class with a capital T dot, let's say\n 2562 04:09:07,030 --> 04:09:12,149 method for this name is static as well, I\n 2563 04:09:12,148 --> 04:09:18,549 I can say test class dot name is equal to\n 2564 04:09:18,549 --> 04:09:22,579 instantiating this object, we can assign a\n 2565 04:09:22,579 --> 04:09:28,250 of that let's move these two line of code\n 2566 04:09:28,250 --> 04:09:33,329 I can also delete this setname method safely.\n 2567 04:09:33,329 --> 04:09:39,890 variable of this test class, I can say something\n 2568 04:09:39,890 --> 04:09:46,489 this time with flirty. That let's say getname.\n 2569 04:09:46,489 --> 04:09:52,010 would be the result. You can see that message\n 2570 04:09:52,010 --> 04:09:59,170 value of this name variable before instantiating\n 2571 04:09:59,170 --> 04:10:04,750 that variable will be the same in all instances\n 2572 04:10:04,750 --> 04:10:09,569 instance of this test class, for example,\nif I say test class 2573 04:10:09,569 --> 04:10:16,879 second test class is equal to new test class,\n 2574 04:10:16,879 --> 04:10:23,648 let's say 30. Black. If I print the name variable\n 2575 04:10:23,648 --> 04:10:30,358 be the same. Let's say second test class dot\n 2576 04:10:30,359 --> 04:10:36,170 Let's run our application, you can see that\n 2577 04:10:36,170 --> 04:10:41,739 methods can be as static as well, let's quickly\n 2578 04:10:41,739 --> 04:10:49,739 let's say public static void. Let's name it\n 2579 04:10:49,739 --> 04:10:56,129 just print something. This static method like\n 2580 04:10:56,129 --> 04:11:02,648 and not to the instances of this object. For\n 2581 04:11:02,648 --> 04:11:08,239 class with a capital T dot print something,\n 2582 04:11:08,239 --> 04:11:13,760 our object. If you're on our application,\n 2583 04:11:13,760 --> 04:11:18,681 now we know that static variables and methods\n 2584 04:11:18,681 --> 04:11:23,609 instances of that object. But why would we\n 2585 04:11:23,609 --> 04:11:28,370 there are a few reasons for that. First of\n 2586 04:11:28,370 --> 04:11:33,780 in all instances of your class. For example,\n 2587 04:11:33,780 --> 04:11:39,260 simulating different employees of a company\n 2588 04:11:39,260 --> 04:11:43,819 about the employee, for example, the age,\n 2589 04:11:43,819 --> 04:11:48,789 all of those, you may have a field called\n 2590 04:11:48,790 --> 04:11:53,740 of your employee class, the company name should\n 2591 04:11:53,739 --> 04:11:59,780 to declare your company name field as a static\n 2592 04:11:59,780 --> 04:12:05,780 and methods is very memory friendly, because\n 2593 04:12:05,780 --> 04:12:11,670 or method in all of your application. So no\n 2594 04:12:11,670 --> 04:12:17,840 application, the company name field in all\n 2595 04:12:17,840 --> 04:12:24,079 as a string can so using a static variables\n 2596 04:12:24,079 --> 04:12:29,170 is a downside when you're working with this\n 2597 04:12:29,170 --> 04:12:35,950 our test class as well. Let's quickly create\n 2598 04:12:35,950 --> 04:12:41,020 Let's name it print, notice that this print\n 2599 04:12:41,020 --> 04:12:46,130 not a static now, we cannot have access to\n 2600 04:12:46,129 --> 04:12:51,709 method for example, in here I cannot say print,\n 2601 04:12:51,709 --> 04:12:57,569 It says that non static method print cannot\n 2602 04:12:57,569 --> 04:13:03,329 to non static methods, you cannot have access\n 2603 04:13:03,329 --> 04:13:09,140 as well. For example, in here if I try to\n 2604 04:13:09,140 --> 04:13:14,309 see that we are getting a red warning in here.\n 2605 04:13:14,309 --> 04:13:20,449 field cannot be referenced from a static context.\n 2606 04:13:20,450 --> 04:13:25,329 inside a static method. Okay, I think that's\n 2607 04:13:25,329 --> 04:13:30,180 Let's quickly delete this class. Also, we\n 2608 04:13:30,180 --> 04:13:35,300 Okay, now we know everything about this main\n 2609 04:13:35,299 --> 04:13:41,369 is public. It's a static method, its return\n 2610 04:13:41,370 --> 04:13:46,470 the input of this method, we are receiving\n 2611 04:13:46,469 --> 04:13:51,849 main method is a static, we know that there\n 2612 04:13:51,850 --> 04:13:57,149 in our entire application. We are not concerned\n 2613 04:13:57,148 --> 04:14:02,269 in order to run Java applications, we need\n 2614 04:14:02,270 --> 04:14:06,760 specific syntax. Okay, that's enough. Let's\n 2615 04:14:06,760 --> 04:14:13,819 talk about in here is inner class. Let's quickly\n 2616 04:14:13,819 --> 04:14:19,309 Inside our classes, besides variables and\n 2617 04:14:19,309 --> 04:14:24,659 here is how we can define that class. We can\n 2618 04:14:24,659 --> 04:14:31,520 name this class test inner class. And here\n 2619 04:14:31,520 --> 04:14:37,200 this in our class, we can have other methods\n 2620 04:14:37,200 --> 04:14:42,409 string name in here. I can have a constructor\n 2621 04:14:42,409 --> 04:14:47,760 that you can see we can create the constructor\n 2622 04:14:47,760 --> 04:14:53,630 And we can treat this class as any other class\n 2623 04:14:53,629 --> 04:14:59,819 a class and an inner class. For example, if\n 2624 04:14:59,819 --> 04:15:07,148 Let's define some, let's say private int,\n 2625 04:15:07,148 --> 04:15:12,409 the access modifier of these fields are, we\n 2626 04:15:12,409 --> 04:15:18,879 in our class. But we need to do that inside\n 2627 04:15:18,879 --> 04:15:26,589 the page. Inside this method, I can say print,\n 2628 04:15:26,590 --> 04:15:31,760 working fine. Even though the access modifier\n 2629 04:15:31,760 --> 04:15:36,380 to that from inside our inner class. The same\n 2630 04:15:36,379 --> 04:15:41,489 Plus, no matter what the access modifier of\n 2631 04:15:41,489 --> 04:15:45,889 them from inside your inner class, there are\n 2632 04:15:45,889 --> 04:15:51,269 classes for example, when you use inner classes,\n 2633 04:15:51,270 --> 04:15:56,030 to follow. The other reason for using inner\n 2634 04:15:56,030 --> 04:16:01,120 access modifier at the declaration of your\n 2635 04:16:01,120 --> 04:16:05,810 public access modifier when we create our\n 2636 04:16:05,809 --> 04:16:11,260 say private you can see an error in here and\n 2637 04:16:11,260 --> 04:16:16,760 privates not allowed in here beside private\n 2638 04:16:16,760 --> 04:16:22,530 classes. That is another benefit of using\n 2639 04:16:22,530 --> 04:16:28,640 when you created your parent class let's quickly\n 2640 04:16:28,639 --> 04:16:34,930 modifier static not allowed in here. So within\n 2641 04:16:34,930 --> 04:16:39,689 classes in this course, we are not going to\n 2642 04:16:39,689 --> 04:16:44,890 first time that we are going to use it is\n 2643 04:16:44,890 --> 04:16:50,170 we are going to define our async tasks as\n 2644 04:16:50,170 --> 04:16:54,430 on in the course. Okay, I think that's a good\n 2645 04:16:54,430 --> 04:16:59,761 to talk about interfaces and abstract classes\n 2646 04:16:59,761 --> 04:17:07,810 have that discussion in the next video. So\n 2647 04:17:07,809 --> 04:17:12,189 As I said at the end of the previous video,\n 2648 04:17:12,189 --> 04:17:19,110 interfaces in Java interfaces are like a contract\n 2649 04:17:19,110 --> 04:17:24,020 see what I mean by that you can create an\n 2650 04:17:24,020 --> 04:17:30,520 you can right click on your package by selecting\n 2651 04:17:30,520 --> 04:17:37,180 interface, you can have an interface Let's\n 2652 04:17:37,180 --> 04:17:41,870 take a look at your package, you can see that\n 2653 04:17:41,870 --> 04:17:46,780 take a closer look, you can see that the icon\n 2654 04:17:46,780 --> 04:17:54,060 the icon of classes in Java. This is the general\n 2655 04:17:54,059 --> 04:17:59,879 interfaces, lives inside the package, they\n 2656 04:17:59,879 --> 04:18:05,329 our interfaces, whatever we want. And also\n 2657 04:18:05,329 --> 04:18:11,930 declaration. Inside interfaces, we can define\n 2658 04:18:11,930 --> 04:18:18,939 abstract method. I can say public, let's say\n 2659 04:18:18,939 --> 04:18:23,970 the input of this method, let's just receive\n 2660 04:18:23,969 --> 04:18:29,159 it, you cannot have a body for your abstract\n 2661 04:18:29,159 --> 04:18:34,049 pair of curly braces, you can see that I'm\n 2662 04:18:34,049 --> 04:18:39,769 that interface abstract methods cannot have\n 2663 04:18:39,770 --> 04:18:46,130 and I can finish my sentence in here. By using\n 2664 04:18:46,129 --> 04:18:50,759 of your methods. For example, in this case,\n 2665 04:18:50,760 --> 04:18:57,290 does. Instead, we are just defining some sort\n 2666 04:18:57,290 --> 04:19:02,050 of our method, we know that the name of this\n 2667 04:19:02,049 --> 04:19:07,219 receiving a string called name. And also we\n 2668 04:19:07,219 --> 04:19:13,139 void. The signature of this method is a contract\n 2669 04:19:13,139 --> 04:19:17,729 we are going to use this signature. Also if\n 2670 04:19:17,729 --> 04:19:22,420 can see that it's somehow grayed out. If you\n 2671 04:19:22,420 --> 04:19:27,960 modifier public is redundant for interface\n 2672 04:19:27,959 --> 04:19:33,898 in here. And the reason for that is because\n 2673 04:19:33,898 --> 04:19:39,989 an interface. It means that you cannot have\n 2674 04:19:39,989 --> 04:19:44,829 your interface. You can have as many abstract\n 2675 04:19:44,829 --> 04:19:51,530 to define another one in here, I can say void.\n 2676 04:19:51,530 --> 04:19:56,070 going to receive anything as the input of\n 2677 04:19:56,069 --> 04:20:02,779 name the spawn move. And also let's receive\n 2678 04:20:02,780 --> 04:20:07,329 method so that I can show you how you can\n 2679 04:20:07,329 --> 04:20:13,219 delete that in here. So this car interface\n 2680 04:20:13,219 --> 04:20:18,449 we use this interface? Let's quickly see that\n 2681 04:20:18,450 --> 04:20:25,030 a Java class called electric car. And inside\n 2682 04:20:25,030 --> 04:20:29,880 that interface that I just created. In order\n 2683 04:20:29,879 --> 04:20:35,529 say implements at the declaration of my class.\n 2684 04:20:35,530 --> 04:20:40,590 of my interface. In this case, it's called\n 2685 04:20:40,590 --> 04:20:45,460 that I'm getting a red warning in here. And\n 2686 04:20:45,459 --> 04:20:50,310 the two methods that we have created inside\n 2687 04:20:50,310 --> 04:20:55,989 two methods, we have multiple options. First\n 2688 04:20:55,989 --> 04:21:01,569 By selecting implement methods, we can implement\n 2689 04:21:01,569 --> 04:21:06,569 you don't see this red light, well, you can\n 2690 04:21:06,569 --> 04:21:12,079 enter, you can see the same dialog or the\n 2691 04:21:12,079 --> 04:21:17,851 of your class. And by pressing Ctrl plus i,\n 2692 04:21:17,851 --> 04:21:23,609 In this case, we have a start and move methods.\n 2693 04:21:23,609 --> 04:21:27,899 the list of all of the methods that you can\n 2694 04:21:27,898 --> 04:21:32,978 bit careful because all of these methods are\n 2695 04:21:32,978 --> 04:21:37,728 are these two methods. If you take a closer\n 2696 04:21:37,728 --> 04:21:43,149 can see that the icon is somehow not completed.\n 2697 04:21:43,149 --> 04:21:49,319 implement or override. Let's select them.\n 2698 04:21:49,319 --> 04:21:54,050 and move method, it means that we can define\n 2699 04:21:54,050 --> 04:21:59,279 here. For example, in the start case, I'm\n 2700 04:21:59,280 --> 04:22:05,739 an electrical car, I'm going to say electricity\n 2701 04:22:05,739 --> 04:22:13,010 this class. I'm going to save private string\n 2702 04:22:13,010 --> 04:22:19,020 ALT plus insert, let's create that constructor.\n 2703 04:22:19,020 --> 04:22:24,550 down in here, let's also define some functionality\n 2704 04:22:24,549 --> 04:22:31,840 to print something, let's say this that getname\n 2705 04:22:31,840 --> 04:22:37,280 Okay, now that we have created this class\n 2706 04:22:37,280 --> 04:22:43,360 we instantiate our interface for that we can\n 2707 04:22:43,360 --> 04:22:50,141 main class, we can say car interface. Let's\n 2708 04:22:50,140 --> 04:22:56,430 I have two options. First of all, I can say\n 2709 04:22:56,430 --> 04:23:01,470 But if I do that, you can see that we are\n 2710 04:23:01,470 --> 04:23:05,623 might be our desired behavior. But in here,\n 2711 04:23:05,623 --> 04:23:06,623 going to say is equal to new electric car.\n 2712 04:23:06,623 --> 04:23:07,623 Tesla, you can see that we are assigning a\n 2713 04:23:07,623 --> 04:23:08,623 Well, because when we have created our class,\n 2714 04:23:08,623 --> 04:23:09,623 is happy with assigning a class to this interface.\n 2715 04:23:09,623 --> 04:23:10,623 we can use its methods. For example, I can\n 2716 04:23:10,623 --> 04:23:11,623 also let's say car interface dot move, we\n 2717 04:23:11,623 --> 04:23:12,623 Let's run the application, you can see that\n 2718 04:23:12,623 --> 04:23:13,623 at 60 miles per hour. You can see that even\n 2719 04:23:13,623 --> 04:23:14,623 any body. But we are printing some functionality.\n 2720 04:23:14,623 --> 04:23:15,623 If you want to make sure that this start method\n 2721 04:23:15,623 --> 04:23:16,623 print something else in here for example,\n 2722 04:23:16,623 --> 04:23:17,623 name of this class. I'm going to pass this\n 2723 04:23:17,623 --> 04:23:18,623 the current object. In this case, it's referring\n 2724 04:23:18,623 --> 04:23:19,623 it will print the address of our class. Let's\n 2725 04:23:19,623 --> 04:23:20,623 of our electric car class. It means that this\n 2726 04:23:20,623 --> 04:23:21,623 car class and not inside the interface. If\n 2727 04:23:21,623 --> 04:23:22,623 we have defined array lists in two ways. One\n 2728 04:23:22,623 --> 04:23:23,623 as list for example, because I've said list\n 2729 04:23:23,623 --> 04:23:24,623 For example, the stuff a string, let's name\n 2730 04:23:24,623 --> 04:23:25,623 now you understand this syntax in here, it\n 2731 04:23:25,623 --> 04:23:26,623 which implements this list interface. If you\n 2732 04:23:26,623 --> 04:23:27,623 you can press down the CTRL key on Windows,\n 2733 04:23:27,623 --> 04:23:28,623 clicking on this ArrayList, you can see the\n 2734 04:23:28,623 --> 04:23:29,623 scroll a bit above in here inside the declaration\n 2735 04:23:29,623 --> 04:23:30,623 are implementing this list. Don't worry about\n 2736 04:23:30,623 --> 04:23:31,623 accept any kind of object but as you can see\n 2737 04:23:31,623 --> 04:23:32,623 on from here. Now that we have our interface,\n 2738 04:23:32,623 --> 04:23:33,623 this interface. Let's quickly create another\n 2739 04:23:33,623 --> 04:23:34,623 this phone fossil fuel car. Once again, in\n 2740 04:23:34,623 --> 04:23:35,623 car interface, we need to implement two methods.\n 2741 04:23:35,623 --> 04:23:36,623 methods. Once again, let's define some functionalities\n 2742 04:23:36,623 --> 04:23:37,623 bring something in here. Let's say explosion\n 2743 04:23:37,623 --> 04:23:38,623 I define some functionality for this move\n 2744 04:23:38,623 --> 04:23:39,623 here like before, I'm going to say private,\n 2745 04:23:39,623 --> 04:23:40,623 and also getters and setters. After that insight,\n 2746 04:23:40,623 --> 04:23:41,623 is moving at some speed. Now that we have\n 2747 04:23:41,623 --> 04:23:42,623 interface inside our main class, like this,\n 2748 04:23:42,623 --> 04:23:43,623 can say car interface. Once again, let's name\n 2749 04:23:43,623 --> 04:23:44,623 Like before, I can say new fossil fuel car.\n 2750 04:23:44,623 --> 04:23:45,623 Once again, you can see that Java compiler\n 2751 04:23:45,623 --> 04:23:46,623 interface because we have implemented this\n 2752 04:23:46,623 --> 04:23:47,623 and also fossil fuel car class, we can instantiate\n 2753 04:23:47,623 --> 04:23:48,623 after that, I can say fosu car interface dot\n 2754 04:23:48,623 --> 04:23:49,623 dot move. Let's also pass some speed in here\n 2755 04:23:49,623 --> 04:23:50,623 that both of these methods have been called\n 2756 04:23:50,623 --> 04:23:51,623 and implement the same interface in both of\n 2757 04:23:51,623 --> 04:23:52,623 an interface, that interface is a contract\n 2758 04:23:52,623 --> 04:23:53,623 For example, in this case, I'm defining multiple\n 2759 04:23:53,623 --> 04:23:54,623 is, the contract says that discourse should\n 2760 04:23:54,623 --> 04:23:55,623 by now you can see the usage of interfaces.\n 2761 04:23:55,623 --> 04:23:56,623 example, we can use something called callback\n 2762 04:23:56,623 --> 04:23:57,623 useful for when you create event listeners\n 2763 04:23:57,623 --> 04:23:58,623 for when you want to create some sort of connection\n 2764 04:23:58,623 --> 04:23:59,623 about threads in the next video, don't worry\n 2765 04:23:59,623 --> 04:24:00,623 when we want to create a communication between\n 2766 04:24:00,623 --> 04:24:01,623 that you can implement multiple interfaces\n 2767 04:24:01,623 --> 04:24:02,623 let's quickly create another interface in\n 2768 04:24:02,623 --> 04:24:03,623 For this, let's just have a method in here.\n 2769 04:24:03,623 --> 04:24:04,623 methods cannot be private, let's say void\nprint name. 2770 04:24:05,623 --> 04:24:06,623 After I have created this interface inside,\n 2771 04:24:06,623 --> 04:24:07,623 the first interface, I can add a comma. And\n 2772 04:24:07,623 --> 04:24:08,623 interface. In this case, it's test interface.\n 2773 04:24:08,623 --> 04:24:09,623 the error somewhere inside the declaration\n 2774 04:24:09,623 --> 04:24:10,623 i can implement my method. So you can have\n 2775 04:24:10,623 --> 04:24:11,623 of your class. Okay, I think that's enough\n 2776 04:24:11,623 --> 04:24:12,623 course we are going to use interfaces a lot\n 2777 04:24:12,623 --> 04:24:13,623 hang in there if something is vague. Okay,\n 2778 04:24:13,623 --> 04:24:14,623 extra interfaces. Let's also delete these\n 2779 04:24:14,623 --> 04:24:15,623 methods. For that I'm going to create a new\n 2780 04:24:15,623 --> 04:24:16,623 class, I'm going to name this fun test abstract\n 2781 04:24:16,623 --> 04:24:17,623 you need to add another keyboard between the\n 2782 04:24:17,623 --> 04:24:18,623 add abstract in here you can see public abstract\n 2783 04:24:18,623 --> 04:24:19,623 abstract keyword, if you take a look at your\n 2784 04:24:19,623 --> 04:24:20,623 class has been changed. This means that this\n 2785 04:24:20,623 --> 04:24:21,623 like interfaces. You can have abstract methods,\n 2786 04:24:21,623 --> 04:24:22,623 say public abstract, let's say void, and let's\n 2787 04:24:22,623 --> 04:24:23,623 name string name. Once again, like interfaces.\n 2788 04:24:23,623 --> 04:24:24,623 have a body. For example, if I put a pair\n 2789 04:24:24,623 --> 04:24:25,623 warning in here like before I can finish my\n 2790 04:24:25,623 --> 04:24:26,623 classes is a lot like interfaces. But there\n 2791 04:24:26,623 --> 04:24:27,623 let's see the first difference in here inside\n 2792 04:24:27,623 --> 04:24:28,623 let's name this one test class. When we wanted\n 2793 04:24:28,623 --> 04:24:29,623 said implements. And after that the name of\n 2794 04:24:29,623 --> 04:24:30,623 classes, we can say extends, let's say extends\n 2795 04:24:30,623 --> 04:24:31,623 the warning again by pressing Ctrl plus if\n 2796 04:24:31,623 --> 04:24:32,623 first difference is between this extends and\n 2797 04:24:32,623 --> 04:24:33,623 that when you want to use abstract classes,\n 2798 04:24:33,623 --> 04:24:34,623 For example, in here, I cannot add a comma\n 2799 04:24:34,623 --> 04:24:35,623 word abstract classes does not support multiple\n 2800 04:24:35,623 --> 04:24:36,623 between an interface and abstract class. The\n 2801 04:24:36,623 --> 04:24:37,623 class, you can also have non abstract methods.\n 2802 04:24:37,623 --> 04:24:38,623 say void. Let's name this method print. Let's\n 2803 04:24:38,623 --> 04:24:39,623 say a string text. And because this is not\n 2804 04:24:39,623 --> 04:24:40,623 this method. We didn't have this option inside\n 2805 04:24:40,623 --> 04:24:41,623 methods inside an abstract class. Like every\n 2806 04:24:41,623 --> 04:24:42,623 a constructor as well. For example, let's\n 2807 04:24:42,623 --> 04:24:43,623 for this class, you can see that all is working\n 2808 04:24:43,623 --> 04:24:44,623 can have fields constructors and non abstract\n 2809 04:24:44,623 --> 04:24:45,623 classes like before we can switch to our main\n 2810 04:24:45,623 --> 04:24:46,623 class. Let's name it test abstract class is\n 2811 04:24:46,623 --> 04:24:47,623 artist abstract class. After that, we can\n 2812 04:24:47,623 --> 04:24:48,623 abstract class dot, let's say print name.\n 2813 04:24:48,623 --> 04:24:49,623 say Mesa, but we didn't have any functionality\n 2814 04:24:49,623 --> 04:24:50,623 some functionality in here. Also know that\n 2815 04:24:50,623 --> 04:24:51,623 we have created a constructor inside our test\n 2816 04:24:51,623 --> 04:24:52,623 in here as well. But for the sake of simplicity,\n 2817 04:24:52,623 --> 04:24:53,623 I just wanted to show that these three options\n 2818 04:24:53,623 --> 04:24:54,623 bring something inside our test class inside\n 2819 04:24:54,623 --> 04:24:55,623 Let's run the application and let's see if\n 2820 04:24:55,623 --> 04:24:56,623 You can see my Sam has been printed. So once\n 2821 04:24:56,623 --> 04:24:57,623 class, we have this abstract method which\n 2822 04:24:57,623 --> 04:24:58,623 this class inside our test class. And we have\n 2823 04:24:58,623 --> 04:24:59,623 class, you can see that there are a lot of\n 2824 04:24:59,623 --> 04:25:00,623 classes. Sometimes the decision for using\n 2825 04:25:00,623 --> 04:25:01,623 for that let me show you an Oracle web page\n 2826 04:25:01,623 --> 04:25:02,623 can see the address in here. I think if you\n 2827 04:25:02,623 --> 04:25:03,623 say that use abstract classes when your classes\n 2828 04:25:03,623 --> 04:25:04,623 is that when you think that the class that\n 2829 04:25:04,623 --> 04:25:05,623 use some common methods or fields or also\n 2830 04:25:05,623 --> 04:25:06,623 than public such as private and protected\n 2831 04:25:06,623 --> 04:25:07,623 declare some fields that are non static and\n 2832 04:25:07,623 --> 04:25:08,623 in interfaces, but they say that Use interfaces\n 2833 04:25:08,623 --> 04:25:09,623 other, or in cases that you want to use multiple\n 2834 04:25:09,623 --> 04:25:10,623 we can implement multiple interfaces. Once\n 2835 04:25:10,623 --> 04:25:11,623 it might be useful. Okay, I think that's enough\n 2836 04:25:11,623 --> 04:25:12,623 to talk about concurrency and threading in\n 2837 04:25:12,623 --> 04:25:13,623 In this video, we are going to talk about\n 2838 04:25:13,623 --> 04:25:14,623 things simultaneously and at the same time.\n 2839 04:25:14,623 --> 04:25:15,623 your phone and you're reading a book at the\n 2840 04:25:15,623 --> 04:25:16,623 music simultaneously, you may be downloading\n 2841 04:25:16,623 --> 04:25:17,623 or doing things at the same time in programming.\n 2842 04:25:17,623 --> 04:25:18,623 order to create a concurrent programming is\n 2843 04:25:18,623 --> 04:25:19,623 in your device's central processing unit or\n 2844 04:25:19,623 --> 04:25:20,623 inside something called a process. All of\n 2845 04:25:20,623 --> 04:25:21,623 CPU. By default, when you run your Java application\n 2846 04:25:21,623 --> 04:25:22,623 a thread called the main thread will be created.\n 2847 04:25:22,623 --> 04:25:23,623 UI thread or the user interface thread as\n 2848 04:25:23,623 --> 04:25:24,623 task, for example, downloading a file, you\n 2849 04:25:24,623 --> 04:25:25,623 thread. The first option in Java that you\n 2850 04:25:25,623 --> 04:25:26,623 You can say thread, let's name this thread\n 2851 04:25:26,623 --> 04:25:27,623 other Java class. Let's finish our sentence\n 2852 04:25:27,623 --> 04:25:28,623 an interface and that interface is the runnable\n 2853 04:25:28,623 --> 04:25:29,623 can say new runnable, you can see that this\n 2854 04:25:29,623 --> 04:25:30,623 runnable interface, this run method will be\n 2855 04:25:30,623 --> 04:25:31,623 place that you put the code that you want\n 2856 04:25:31,623 --> 04:25:32,623 example, let's print something in here. And\n 2857 04:25:32,623 --> 04:25:33,623 For example, let's say hello from another\n 2858 04:25:33,623 --> 04:25:34,623 need to come down after the declaration of\n 2859 04:25:34,623 --> 04:25:35,623 run our application. And let's see if we can\n 2860 04:25:35,623 --> 04:25:36,623 has been printed into the console. But how\n 2861 04:25:36,623 --> 04:25:37,623 thread and this worker thread for that I am\n 2862 04:25:37,623 --> 04:25:38,623 example, inside this run method, I'm going\n 2863 04:25:38,623 --> 04:25:39,623 is equal to zero, i less than, let's say five,\n 2864 04:25:39,623 --> 04:25:40,623 going to print the value of this I and after\n 2865 04:25:40,623 --> 04:25:41,623 see how we can asleep the current thread.\n 2866 04:25:41,623 --> 04:25:42,623 say plus I plus, let's say in a worker thread.\n 2867 04:25:42,623 --> 04:25:43,623 options. The first one and I believe the easiest\n 2868 04:25:43,623 --> 04:25:44,623 say thread with a capital T dot sleep. Inside\n 2869 04:25:44,623 --> 04:25:45,623 to pass some numbers in milliseconds. For\n 2870 04:25:45,623 --> 04:25:46,623 second, I need to pass 1000 milliseconds this\n 2871 04:25:46,623 --> 04:25:47,623 wait one second for the next record for example\n 2872 04:25:47,623 --> 04:25:48,623 we are going to wait one second. And after\n 2873 04:25:48,623 --> 04:25:49,623 as you can see, we are getting a warning in\n 2874 04:25:49,623 --> 04:25:50,623 Java dot Lang dot interrupted exception. In\n 2875 04:25:50,623 --> 04:25:51,623 about exceptions. We will talk about them\n 2876 04:25:51,623 --> 04:25:52,623 need to know that whenever an exception occurs,\n 2877 04:25:52,623 --> 04:25:53,623 that, we need to do something for this error\n 2878 04:25:53,623 --> 04:25:54,623 error in here is to click on the error and\n 2879 04:25:54,623 --> 04:25:55,623 this surround with try catch, you can see\n 2880 04:25:55,623 --> 04:25:56,623 dot sleep method has been moved to this try\n 2881 04:25:56,623 --> 04:25:57,623 for now let's move on from this part. And\n 2882 04:25:57,623 --> 04:25:58,623 thread so that we can see that the code inside\n 2883 04:25:58,623 --> 04:25:59,623 be executed at the same time. So basically,\n 2884 04:25:59,623 --> 04:26:00,623 it from here and inside the main thread outside\n 2885 04:26:00,623 --> 04:26:01,623 here. I'm just going to change this message\n 2886 04:26:01,623 --> 04:26:02,623 and let's see If this code is going to work,\n 2887 04:26:02,623 --> 04:26:03,623 of oil two times. Once in a worker thread,\n 2888 04:26:03,623 --> 04:26:04,623 the code inside the worker thread and the\n 2889 04:26:04,623 --> 04:26:05,623 at the same time. In this situation, we say\n 2890 04:26:05,623 --> 04:26:06,623 is concurrent. So once again, when you run\n 2891 04:26:06,623 --> 04:26:07,623 will be created by default, in which we call\n 2892 04:26:07,623 --> 04:26:08,623 After that inside that main thread, you can\n 2893 04:26:08,623 --> 04:26:09,623 The simplest way to create a thread is to\n 2894 04:26:09,623 --> 04:26:10,623 And after that, we can pass a new runnable\n 2895 04:26:10,623 --> 04:26:11,623 we will create this run method that will be\n 2896 04:26:11,623 --> 04:26:12,623 way of defining your thread, there are a lot\n 2897 04:26:12,623 --> 04:26:13,623 about. For example, you need to be worried\n 2898 04:26:13,623 --> 04:26:14,623 is done. Also, there are all sorts of new\n 2899 04:26:14,623 --> 04:26:15,623 and interrupting your thread. I do not intend\n 2900 04:26:15,623 --> 04:26:16,623 because in Android, we have all sorts of options\n 2901 04:26:16,623 --> 04:26:17,623 fact, later on in the course, we have a complete\n 2902 04:26:17,623 --> 04:26:18,623 In Android, we have options like async, task\n 2903 04:26:18,623 --> 04:26:19,623 we are going to talk about all of them. But\n 2904 04:26:19,623 --> 04:26:20,623 talk about this interrupted exception that\n 2905 04:26:20,623 --> 04:26:21,623 an exception occurs, your application will\n 2906 04:26:21,623 --> 04:26:22,623 by the operating system. There are all sorts\n 2907 04:26:22,623 --> 04:26:23,623 the ones that we have seen previously, were\n 2908 04:26:23,623 --> 04:26:24,623 and the one that we can see in here is interrupted\n 2909 04:26:24,623 --> 04:26:25,623 need to do something about the exception.\n 2910 04:26:25,623 --> 04:26:26,623 we can do about the exceptions. 2911 04:26:26,623 --> 04:26:27,623 Let's create an application in which we will\n 2912 04:26:27,623 --> 04:26:28,623 going to define two new integers. For example,\n 2913 04:26:28,623 --> 04:26:29,623 b is equal to zero. Let's bring something\n 2914 04:26:29,623 --> 04:26:30,623 we run our application, right, now, we should\n 2915 04:26:30,623 --> 04:26:31,623 down in here. The thing that we can do about\n 2916 04:26:31,623 --> 04:26:32,623 it happens, and we can do that by using a\n 2917 04:26:32,623 --> 04:26:33,623 example, I can say try. Let's move this line\n 2918 04:26:33,623 --> 04:26:34,623 try this in case some exception happens catch\n 2919 04:26:34,623 --> 04:26:35,623 arithmetic exception. So let's say arithmetic\n 2920 04:26:35,623 --> 04:26:36,623 inside the catch block, we can do something\n 2921 04:26:36,623 --> 04:26:37,623 something. In this case, let's say B was zero.\n 2922 04:26:37,623 --> 04:26:38,623 get an exception. Instead, we are printing\n 2923 04:26:38,623 --> 04:26:39,623 not to be useful. And in fact, in most cases,\n 2924 04:26:39,623 --> 04:26:40,623 purposes, but it's much better than a crash.\n 2925 04:26:40,623 --> 04:26:41,623 in here is arithmetic exception. If we do\n 2926 04:26:41,623 --> 04:26:42,623 the generic term exception. If you pass this\n 2927 04:26:42,623 --> 04:26:43,623 exceptions. If we run our application, once\n 2928 04:26:43,623 --> 04:26:44,623 here is the same result. The other kind of\n 2929 04:26:44,623 --> 04:26:45,623 pointer exception that would occur when we\n 2930 04:26:45,623 --> 04:26:46,623 For example, if we had a string in here, let's\n 2931 04:26:46,623 --> 04:26:47,623 some operation on our name inside the try\n 2932 04:26:47,623 --> 04:26:48,623 let's say, Mesa, if we do that, we are going\n 2933 04:26:48,623 --> 04:26:49,623 have done this dot equals method on a null\n 2934 04:26:49,623 --> 04:26:50,623 of saying B was zero, let's say name was no.\n 2935 04:26:50,623 --> 04:26:51,623 work fine because we are passing the generic\n 2936 04:26:51,623 --> 04:26:52,623 pointer exception. Let's run the application.\n 2937 04:26:52,623 --> 04:26:53,623 of exception that we just saw was this interrupted\n 2938 04:26:53,623 --> 04:26:54,623 interrupt the current thread. For example,\n 2939 04:26:54,623 --> 04:26:55,623 downloading some file at the same time, you\n 2940 04:26:55,623 --> 04:26:56,623 the interrupted exception, you may get a crash.\n 2941 04:26:56,623 --> 04:26:57,623 we have audio exception, which stands for\n 2942 04:26:57,623 --> 04:26:58,623 exception, we have all sorts of other exceptions\n 2943 04:26:58,623 --> 04:26:59,623 we face them. Also on our exception, we have\n 2944 04:26:59,623 --> 04:27:00,623 that method is called print stack trace, we\n 2945 04:27:00,623 --> 04:27:01,623 a stack trace, we will talk about this stack\n 2946 04:27:01,623 --> 04:27:02,623 and fragments in Android. But for now, just\n 2947 04:27:02,623 --> 04:27:03,623 to print something into our console that might\n 2948 04:27:03,623 --> 04:27:04,623 Let's run the application in here. You can\n 2949 04:27:04,623 --> 04:27:05,623 it says that the exception occurred in line\n 2950 04:27:05,623 --> 04:27:06,623 the name of your exception, this is not an\n 2951 04:27:06,623 --> 04:27:07,623 information about your exception, this in\n 2952 04:27:07,623 --> 04:27:08,623 your application. Okay, I think that's enough\n 2953 04:27:08,623 --> 04:27:09,623 Java. In the next video, we are going to talk\n 2954 04:27:09,623 --> 04:27:10,623 the next video. In this video, we are going\n 2955 04:27:10,623 --> 04:27:11,623 we use Singleton pattern when we want to make\n 2956 04:27:11,623 --> 04:27:12,623 class in our entire application. In some cases,\n 2957 04:27:12,623 --> 04:27:13,623 we can implement that pattern. For example,\n 2958 04:27:13,623 --> 04:27:14,623 you are using a database in your application.\n 2959 04:27:14,623 --> 04:27:15,623 complete section dedicated to them. But in\n 2960 04:27:15,623 --> 04:27:16,623 Java class named database. Let's quickly create\n 2961 04:27:16,623 --> 04:27:17,623 And we will see how we can implement that\n 2962 04:27:17,623 --> 04:27:18,623 this database class, I'm going to define a\n 2963 04:27:18,623 --> 04:27:19,623 let's create a constructor and also getters\nand setters. 2964 04:27:19,623 --> 04:27:20,623 Right now, because we have this public constructor,\n 2965 04:27:20,623 --> 04:27:21,623 from this database class. But if you want\n 2966 04:27:21,623 --> 04:27:22,623 of this class in your entire application,\n 2967 04:27:22,623 --> 04:27:23,623 example, I'm going to say private, static\n 2968 04:27:23,623 --> 04:27:24,623 to specify the class that we are in for example,\n 2969 04:27:24,623 --> 04:27:25,623 let's say private static database, make sure\n 2970 04:27:25,623 --> 04:27:26,623 or dot maker dot Singleton pattern. For the\n 2971 04:27:26,623 --> 04:27:27,623 it instance. And that's it. Now we can create\n 2972 04:27:27,623 --> 04:27:28,623 how we can create that field, we can say public,\n 2973 04:27:28,623 --> 04:27:29,623 inside this field, I'm going to say static,\n 2974 04:27:29,623 --> 04:27:30,623 to be the class itself. So I'm going to say\n 2975 04:27:30,623 --> 04:27:31,623 as you can see the suggestion in here and\n 2976 04:27:31,623 --> 04:27:32,623 instead of just simply passing this instance,\n 2977 04:27:32,623 --> 04:27:33,623 to say if let's say now, is equal to our instance,\n 2978 04:27:33,623 --> 04:27:34,623 new instance, I'm going to say instance, is\n 2979 04:27:34,623 --> 04:27:35,623 a name for the constructor of this database.\n 2980 04:27:35,623 --> 04:27:36,623 input of this method in here, let's say the\n 2981 04:27:36,623 --> 04:27:37,623 naming here. So if our instance is now we\n 2982 04:27:37,623 --> 04:27:38,623 creating that we are going to return it, we\n 2983 04:27:38,623 --> 04:27:39,623 case, in case if our instance is not not in\n 2984 04:27:39,623 --> 04:27:40,623 instance, right now if we use this get instance\n 2985 04:27:40,623 --> 04:27:41,623 sure that we have only one instance of our\n 2986 04:27:41,623 --> 04:27:42,623 For example, if we go to the main class, and\n 2987 04:27:42,623 --> 04:27:43,623 can have only one instance we can say database,\n 2988 04:27:43,623 --> 04:27:44,623 with capital D dot get instance, of course,\n 2989 04:27:44,623 --> 04:27:45,623 For example, let's say DB music. Notice that\n 2990 04:27:45,623 --> 04:27:46,623 method as a static, now we can use this database\n 2991 04:27:46,623 --> 04:27:47,623 are not relying on the instance of this database\n 2992 04:27:47,623 --> 04:27:48,623 But right now someone can declare the database\n 2993 04:27:48,623 --> 04:27:49,623 in here, someone can say database. Let's name\n 2994 04:27:49,623 --> 04:27:50,623 is equal to new database because in our database\n 2995 04:27:50,623 --> 04:27:51,623 a name in here and if we do that, we have\n 2996 04:27:51,623 --> 04:27:52,623 example, let's say DB movies. In order to\n 2997 04:27:52,623 --> 04:27:53,623 I'm going to change the access modifier of\n 2998 04:27:53,623 --> 04:27:54,623 I'm going to change this public to private,\n 2999 04:27:54,623 --> 04:27:55,623 only from inside this class and not from inside\n 3000 04:27:55,623 --> 04:27:56,623 now we have an error in here and the error\n 3001 04:27:56,623 --> 04:27:57,623 changing the access modifier from public to\n 3002 04:27:57,623 --> 04:27:58,623 creating multiple instances of our database\n 3003 04:27:58,623 --> 04:27:59,623 our database is private, we can use this constructor\n 3004 04:27:59,623 --> 04:28:00,623 see in line 10, in here, right now, because\n 3005 04:28:00,623 --> 04:28:01,623 this, if statement that we have put in here,\n 3006 04:28:01,623 --> 04:28:02,623 of our database class. But there is also another\n 3007 04:28:02,623 --> 04:28:03,623 that's when someone tries to create multiple\n 3008 04:28:03,623 --> 04:28:04,623 In some cases, if someone tries to create\n 3009 04:28:04,623 --> 04:28:05,623 they might be successful in doing such a thing.\n 3010 04:28:05,623 --> 04:28:06,623 safe, we have an option in here after this\n 3011 04:28:06,623 --> 04:28:07,623 in which we haven't seen so far, we can say\n 3012 04:28:07,623 --> 04:28:08,623 make our get instance method thread safe,\n 3013 04:28:08,623 --> 04:28:09,623 call this get instance at the same time. So\n 3014 04:28:09,623 --> 04:28:10,623 of all, you declare a static field of the\n 3015 04:28:10,623 --> 04:28:11,623 database, after that, you create a get instance\n 3016 04:28:11,623 --> 04:28:12,623 also synchronized. Inside that get instance\n 3017 04:28:12,623 --> 04:28:13,623 of your database is now or not, if it is not,\n 3018 04:28:13,623 --> 04:28:14,623 are calling this get instance method. So you\n 3019 04:28:14,623 --> 04:28:15,623 doing in line 10. After that, we are returning\n 3020 04:28:15,623 --> 04:28:16,623 not going to create a new instance, we are\n 3021 04:28:16,623 --> 04:28:17,623 beside this get instance method. In order\n 3022 04:28:17,623 --> 04:28:18,623 you need to change the access modifier of\n 3023 04:28:18,623 --> 04:28:19,623 be usable only inside your database class.\n 3024 04:28:19,623 --> 04:28:20,623 for example, in here, I can delete this whole\n 3025 04:28:20,623 --> 04:28:21,623 from line 11 in here, and after the if statement,\n 3026 04:28:21,623 --> 04:28:22,623 we reach to this line 13 in which we are returning\n 3027 04:28:22,623 --> 04:28:23,623 is not not and we are returning either a new\n 3028 04:28:23,623 --> 04:28:24,623 think that's enough talking about the singleton\n 3029 04:28:24,623 --> 04:28:25,623 that this pattern might be useful from time\n 3030 04:28:25,623 --> 04:28:26,623 going to talk about one more methods available\n 3031 04:28:26,623 --> 04:28:27,623 called to string right now we don't have any\n 3032 04:28:27,623 --> 04:28:28,623 But if we switch back to the main class, and\n 3033 04:28:28,623 --> 04:28:29,623 see that we have such a method. And if we\n 3034 04:28:29,623 --> 04:28:30,623 about our database class. Let's quickly run\n 3035 04:28:30,623 --> 04:28:31,623 You can see that we are getting the address\n 3036 04:28:31,623 --> 04:28:32,623 change this for example inside your database\n 3037 04:28:32,623 --> 04:28:33,623 down in here inside the scope of our class,\n 3038 04:28:33,623 --> 04:28:34,623 can select this two string method. Right now\n 3039 04:28:34,623 --> 04:28:35,623 want to change that we can delete this whole\n 3040 04:28:35,623 --> 04:28:36,623 here. For example, we can say a string text\n 3041 04:28:36,623 --> 04:28:37,623 that, let's add a line. And after that, let's\n 3042 04:28:37,623 --> 04:28:38,623 Let's say name plus the start name. After\n 3043 04:28:38,623 --> 04:28:39,623 we can say return text. Now that we have overrided,\n 3044 04:28:39,623 --> 04:28:40,623 we should see some other results printed into\n 3045 04:28:40,623 --> 04:28:41,623 method can be useful as well. It's available\n 3046 04:28:41,623 --> 04:28:42,623 print some detail about that class. Okay,\n 3047 04:28:42,623 --> 04:28:43,623 for that method. I think that's enough talking\n 3048 04:28:43,623 --> 04:28:44,623 we have learned a lot in the next video we\n 3049 04:28:44,623 --> 04:28:45,623 to make sure that we have learned everything\n 3050 04:28:45,623 --> 04:28:46,623 off this video, I'm going to say that with\n 3051 04:28:46,623 --> 04:28:47,623 besides writing Android applications, you\n 3052 04:28:47,623 --> 04:28:48,623 for Windows, Linux and Mac OS operating systems.\n 3053 04:28:48,623 --> 04:28:49,623 you can use Java in order to create enterprise\n 3054 04:28:49,623 --> 04:28:50,623 language. For example, you can use Java in\n 3055 04:28:50,623 --> 04:28:51,623 You can also use it for data analysis purposes,\n 3056 04:28:51,623 --> 04:28:52,623 In this course we have touched the surface\n 3057 04:28:52,623 --> 04:28:53,623 more, I'm currently recording a new course\n 3058 04:28:53,623 --> 04:28:54,623 find that course helpful beside the Java course\n 3059 04:28:54,623 --> 04:28:55,623 framework in order to create web applications.\n 3060 04:28:55,623 --> 04:28:56,623 courses may be released, so make sure to check\n 3061 04:28:56,623 --> 04:28:57,623 next video, as I said, we are going to have\n 3062 04:28:57,623 --> 04:28:58,623 Here is our final challenge for the Java section,\n 3063 04:28:58,623 --> 04:28:59,623 and messages applications. Here is how our\n 3064 04:28:59,623 --> 04:29:00,623 we are going to greet the user with some message.\n 3065 04:29:00,623 --> 04:29:01,623 to the user, one for managing the contacts,\n 3066 04:29:01,623 --> 04:29:02,623 another one for creating the application.\n 3067 04:29:02,623 --> 04:29:03,623 which is managing the contacts, we are going\n 3068 04:29:03,623 --> 04:29:04,623 of the contacts another one for adding a new\n 3069 04:29:04,623 --> 04:29:05,623 contact. One more for deleting a contact.\n 3070 04:29:05,623 --> 04:29:06,623 menu, which was these three options. But in\n 3071 04:29:06,623 --> 04:29:07,623 which is handling messages, we are going to\n 3072 04:29:07,623 --> 04:29:08,623 to see a list of all of the messages. The\n 3073 04:29:08,623 --> 04:29:09,623 last one in order to go back to the previous\n 3074 04:29:09,623 --> 04:29:10,623 three options. In case if the user selects\n 3075 04:29:10,623 --> 04:29:11,623 the application. We haven't talked about databases\n 3076 04:29:11,623 --> 04:29:12,623 if you want to store contacts and messages,\n 3077 04:29:12,623 --> 04:29:13,623 the video in here and go solve the challenge.\n 3078 04:29:13,623 --> 04:29:14,623 for this application. Okay, let's go to see\n 3079 04:29:14,623 --> 04:29:15,623 First of all, I have created my project, and\n 3080 04:29:15,623 --> 04:29:16,623 folder. Inside this package I have created\n 3081 04:29:16,623 --> 04:29:17,623 method. Let's continue from here. First of\n 3082 04:29:17,623 --> 04:29:18,623 called message. Inside this message class,\n 3083 04:29:18,623 --> 04:29:19,623 private string text. Another one, let's say\n 3084 04:29:19,623 --> 04:29:20,623 here is going to be the name of our contact.\n 3085 04:29:20,623 --> 04:29:21,623 called ID, let's say private int ID. This\n 3086 04:29:21,623 --> 04:29:22,623 here. But because in most cases, when you're\n 3087 04:29:22,623 --> 04:29:23,623 called ID in order to identify every unique\n 3088 04:29:23,623 --> 04:29:24,623 a real world application. I just wanted you\n 3089 04:29:24,623 --> 04:29:25,623 is a message. Okay, now that we have these\n 3090 04:29:25,623 --> 04:29:26,623 And let's accept all of these three fields.\n 3091 04:29:26,623 --> 04:29:27,623 I'm not sure that we are going to need all\n 3092 04:29:27,623 --> 04:29:28,623 we didn't use them, we will delete them. Also\n 3093 04:29:28,623 --> 04:29:29,623 another method called get details. Basically,\n 3094 04:29:29,623 --> 04:29:30,623 message. So let's say public void. Let's name\nit get details. 3095 04:29:30,623 --> 04:29:31,623 Let's say print. First of all, let's say contact\n 3096 04:29:31,623 --> 04:29:32,623 that, let's print the text itself. Let's say\n 3097 04:29:32,623 --> 04:29:33,623 a plus in here. Sorry about that. And I think\n 3098 04:29:33,623 --> 04:29:34,623 be much better. After the text. Let's also\n 3099 04:29:34,623 --> 04:29:35,623 our ID. That's it for our message class, let's\n 3100 04:29:35,623 --> 04:29:36,623 New Java class, let's name this phone contact.\n 3101 04:29:36,623 --> 04:29:37,623 four fields, let's say private string, name,\n 3102 04:29:37,623 --> 04:29:38,623 this number should be an integer, or maybe\n 3103 04:29:38,623 --> 04:29:39,623 have different formats. For example, they\n 3104 04:29:39,623 --> 04:29:40,623 I am saving this number as a string. But if\n 3105 04:29:40,623 --> 04:29:41,623 After name and number, I'm going to save another\n 3106 04:29:41,623 --> 04:29:42,623 After all of these, I'm going to have another\n 3107 04:29:42,623 --> 04:29:43,623 of different messages. Let's name this phone\n 3108 04:29:43,623 --> 04:29:44,623 different messages for every contact inside\n 3109 04:29:44,623 --> 04:29:45,623 fields, let's quickly create our constructor.\n 3110 04:29:45,623 --> 04:29:46,623 because at the time of creating a new contact,\n 3111 04:29:46,623 --> 04:29:47,623 that, I'm going to create another constructor\n 3112 04:29:47,623 --> 04:29:48,623 of different messages. This time, let's select\n 3113 04:29:48,623 --> 04:29:49,623 do anything about this messages, this ArrayList\n 3114 04:29:49,623 --> 04:29:50,623 to see these dots messages is equal to new\n 3115 04:29:50,623 --> 04:29:51,623 contact, I'm saving the messages array list\n 3116 04:29:51,623 --> 04:29:52,623 have two constructors in here, let's quickly\n 3117 04:29:52,623 --> 04:29:53,623 that, let's create a get details method. Let's\n 3118 04:29:53,623 --> 04:29:54,623 use two string methods. But in here, I'm just\n 3119 04:29:54,623 --> 04:29:55,623 let's print all of the information about each\n 3120 04:29:55,623 --> 04:29:56,623 After that, let's print the number and email.\n 3121 04:29:56,623 --> 04:29:57,623 switch to main class. And let's write the\n 3122 04:29:57,623 --> 04:29:58,623 here, I'm going to create an ArrayList of\n 3123 04:29:58,623 --> 04:29:59,623 that inside this main method because we are\n 3124 04:29:59,623 --> 04:30:00,623 to have access to our contacts are released\n 3125 04:30:00,623 --> 04:30:01,623 define my ArrayList above in here in the fields\n 3126 04:30:01,623 --> 04:30:02,623 because the methods that I'm going to use\n 3127 04:30:02,623 --> 04:30:03,623 this ArrayList as a static, so let's say private\n 3128 04:30:03,623 --> 04:30:04,623 name it contacts. But this is not a good place\n 3129 04:30:04,623 --> 04:30:05,623 this is not the place that our code will be\n 3130 04:30:05,623 --> 04:30:06,623 for example, inside this main method. But\n 3131 04:30:06,623 --> 04:30:07,623 a scanner in here because we are going to\n 3132 04:30:07,623 --> 04:30:08,623 say private static scanner, let's name it\n 3133 04:30:08,623 --> 04:30:09,623 let's initialize our contacts ArrayList. Let's\n 3134 04:30:09,623 --> 04:30:10,623 you can see in here, I'm going to greet the\n 3135 04:30:10,623 --> 04:30:11,623 After that, I'm going to show these three\n 3136 04:30:11,623 --> 04:30:12,623 to have a clean code. I'm going to show these\n 3137 04:30:12,623 --> 04:30:13,623 name that method show initial options. But\n 3138 04:30:13,623 --> 04:30:14,623 warning and that's because I need to create\n 3139 04:30:14,623 --> 04:30:15,623 static void, show initial options. Let's bring\n 3140 04:30:15,623 --> 04:30:16,623 get the user's input. And for that we can\n 3141 04:30:16,623 --> 04:30:17,623 Right now we have declared our scanner above\n 3142 04:30:17,623 --> 04:30:18,623 a good place to initialize our scanner in\n 3143 04:30:18,623 --> 04:30:19,623 scanner. Let's pass the system that after\n 3144 04:30:19,623 --> 04:30:20,623 scanner dot next int. Let's create a switch\n 3145 04:30:20,623 --> 04:30:21,623 In case the choice is one, we are going to\n 3146 04:30:21,623 --> 04:30:22,623 that in another method, let's say manage contacts.\n 3147 04:30:22,623 --> 04:30:23,623 create this method later on. Let's also add\n 3148 04:30:23,623 --> 04:30:24,623 is to, we are going to handle the messages.\n 3149 04:30:24,623 --> 04:30:25,623 choice is three, or for that matter, any other\n 3150 04:30:25,623 --> 04:30:26,623 So in here, I can say default. In the default\n 3151 04:30:26,623 --> 04:30:27,623 Let's minimize this project main for now.\n 3152 04:30:27,623 --> 04:30:28,623 First of all, let's manage our contacts. Let's\n 3153 04:30:28,623 --> 04:30:29,623 Once again, in here, I'm going to show a list\n 3154 04:30:29,623 --> 04:30:30,623 One, once again, we need to get the user's\n 3155 04:30:30,623 --> 04:30:31,623 say int choice is equal to a scanner dot next\n 3156 04:30:31,623 --> 04:30:32,623 scanner in here. And that's because we have\n 3157 04:30:32,623 --> 04:30:33,623 method. So by this time, we have an instance\n 3158 04:30:33,623 --> 04:30:34,623 need to create a switch on our choice. In\n 3159 04:30:34,623 --> 04:30:35,623 the contacts, let's create that method, show\n 3160 04:30:35,623 --> 04:30:36,623 also write the rest of the cases. In the default\n 3161 04:30:36,623 --> 04:30:37,623 menu. So I'm going to once again run this\n 3162 04:30:37,623 --> 04:30:38,623 see all of these options once again. So in\n 3163 04:30:38,623 --> 04:30:39,623 options. After that in here, we need a default\n 3164 04:30:39,623 --> 04:30:40,623 I'm going to go back to the previous menu\n 3165 04:30:40,623 --> 04:30:41,623 Okay, let's create these methods one by one.\n 3166 04:30:41,623 --> 04:30:42,623 the contacts. I'm going to do that down in\n 3167 04:30:42,623 --> 04:30:43,623 of your method, you can use the help of your\n 3168 04:30:43,623 --> 04:30:44,623 in here and by pressing ALT plus insert, the\n 3169 04:30:44,623 --> 04:30:45,623 can see that we have created this method successfully,\n 3170 04:30:45,623 --> 04:30:46,623 down in here, I can't create the logic for\n 3171 04:30:46,623 --> 04:30:47,623 of the contacts, I'm going to simply create\n 3172 04:30:47,623 --> 04:30:48,623 name it see inside our contacts, or at least,\n 3173 04:30:48,623 --> 04:30:49,623 that we have created inside our contact class.\n 3174 04:30:49,623 --> 04:30:50,623 show the initial options. For that I'm going\n 3175 04:30:50,623 --> 04:30:51,623 to quit the application when the user tells\n 3176 04:30:51,623 --> 04:30:52,623 Let's just minimize it for now. And let's\n 3177 04:30:52,623 --> 04:30:53,623 contacts. Once again, we can use the help\n 3178 04:30:53,623 --> 04:30:54,623 we are going to receive some users input.\n 3179 04:30:54,623 --> 04:30:55,623 Let's say adding a new contact. After that,\n 3180 04:30:55,623 --> 04:30:56,623 Once again, we are going to use our scanner,\n 3181 04:30:56,623 --> 04:30:57,623 dot next, after we get the contacts name,\n 3182 04:30:57,623 --> 04:30:58,623 once again, let's bring something in here.\n 3183 04:30:58,623 --> 04:30:59,623 see string number is equal to a scanner dot\n 3184 04:30:59,623 --> 04:31:00,623 he made is equal to a scanner dot next. After\n 3185 04:31:00,623 --> 04:31:01,623 something as the name number and email of\n 3186 04:31:01,623 --> 04:31:02,623 leave us with empty strings. For that, I'm\n 3187 04:31:03,623 --> 04:31:04,623 name dot equals an empty string. Let's say\n 3188 04:31:04,623 --> 04:31:05,623 Or if email is equal to an empty string. If\n 3189 04:31:05,623 --> 04:31:06,623 show some message to the user we are going\n 3190 04:31:06,623 --> 04:31:07,623 Let's say please enter all of the information.\n 3191 04:31:07,623 --> 04:31:08,623 to recall this whole method I'm going to start\n 3192 04:31:08,623 --> 04:31:09,623 I'm going to say add new contact. I'm calling\n 3193 04:31:09,623 --> 04:31:10,623 called a recursive call, you can see the icon\n 3194 04:31:10,623 --> 04:31:11,623 that you can see the recursive call calling\n 3195 04:31:11,623 --> 04:31:12,623 way of calling our method, we are starting\n 3196 04:31:12,623 --> 04:31:13,623 but in the else case, we are going to create\n 3197 04:31:13,623 --> 04:31:14,623 let's name it contact is equal to new contact.\n 3198 04:31:14,623 --> 04:31:15,623 and email. If you remember inside our contact\n 3199 04:31:15,623 --> 04:31:16,623 we are using the second constructor, we didn't\n 3200 04:31:16,623 --> 04:31:17,623 in here. After creating our contact object,\n 3201 04:31:17,623 --> 04:31:18,623 Let's pass our contact. As simple as that.\n 3202 04:31:18,623 --> 04:31:19,623 if statement. Once again, I'm going to show\n 3203 04:31:19,623 --> 04:31:20,623 options. Because once again, we are not going\n 3204 04:31:20,623 --> 04:31:21,623 tells us Ok, we are done with our second method.\n 3205 04:31:21,623 --> 04:31:22,623 create this search for contact method. The\n 3206 04:31:22,623 --> 04:31:23,623 method first of all we are going to ask for\n 3207 04:31:23,623 --> 04:31:24,623 let's say please enter the contact name. Let's\n 3208 04:31:24,623 --> 04:31:25,623 next. After that we need to make sure that\n 3209 04:31:25,623 --> 04:31:26,623 dot equals an empty string. We are going to\n 3210 04:31:26,623 --> 04:31:27,623 the contact name once again. Let's say please\n 3211 04:31:27,623 --> 04:31:28,623 are going to use a recursive call. We are\n 3212 04:31:28,623 --> 04:31:29,623 But in the else case, we are going to search\n 3213 04:31:29,623 --> 04:31:30,623 For that once again I'm going to create a\n 3214 04:31:30,623 --> 04:31:31,623 name it see inside our contacts are a list.\n 3215 04:31:31,623 --> 04:31:32,623 name that we just received. If that's the\n 3216 04:31:32,623 --> 04:31:33,623 also define a Boolean before this for loop.\n 3217 04:31:33,623 --> 04:31:34,623 Let's say Boolean. Let's name it does exist.\n 3218 04:31:34,623 --> 04:31:35,623 Wherever you have found the contact first\n 3219 04:31:35,623 --> 04:31:36,623 does exist to true, let's say it does exist\n 3220 04:31:36,623 --> 04:31:37,623 I'm going to create an if statement, I'm going\n 3221 04:31:37,623 --> 04:31:38,623 Then we are going to print something I'm going\n 3222 04:31:38,623 --> 04:31:39,623 After all of these logics, we are going to\n 3223 04:31:39,623 --> 04:31:40,623 say show initial options. Okay, that's it\n 3224 04:31:40,623 --> 04:31:41,623 create this delete contact method. Once again,\n 3225 04:31:41,623 --> 04:31:42,623 name. So let's say please enter the name.\n 3226 04:31:42,623 --> 04:31:43,623 to a scanner dot next, next, we need to create\n 3227 04:31:43,623 --> 04:31:44,623 empty string, we are going to ask for the\n 3228 04:31:44,623 --> 04:31:45,623 from the beginning of this method. In the\n 3229 04:31:45,623 --> 04:31:46,623 ArrayList. So let's say for contact see inside\n 3230 04:31:46,623 --> 04:31:47,623 let's also define a Boolean above in here\n 3231 04:31:47,623 --> 04:31:48,623 Let's say Boolean does exist. Let's initialize\n 3232 04:31:48,623 --> 04:31:49,623 know why I said as in here, let's quickly\n 3233 04:31:49,623 --> 04:31:50,623 that gets name is equal to the name that we\n 3234 04:31:50,623 --> 04:31:51,623 all, we are going to change the value of this\n 3235 04:31:51,623 --> 04:31:52,623 to true. After that, we are going to remove\n 3236 04:31:52,623 --> 04:31:53,623 can save contact dot remove. This remove method\n 3237 04:31:53,623 --> 04:31:54,623 see the object that we are currently looking\n 3238 04:31:54,623 --> 04:31:55,623 going to say if does exist is not equal to\n 3239 04:31:55,623 --> 04:31:56,623 such contact. And after all of these logics,\n 3240 04:31:56,623 --> 04:31:57,623 initial options. Okay, that's it for this\n 3241 04:31:57,623 --> 04:31:58,623 have created the logic for the first option\n 3242 04:31:58,623 --> 04:31:59,623 whole logic for this manage contacts. But\n 3243 04:31:59,623 --> 04:32:00,623 option, we have one or two possible points\n 3244 04:32:00,623 --> 04:32:01,623 two and also we are going to write the rest\n 3245 04:32:01,623 --> 04:32:02,623 video. See you in the next video. 3246 04:32:02,623 --> 04:32:03,623 In the previous video, we have created the\n 3247 04:32:03,623 --> 04:32:04,623 if you remember I said that we have some issues\n 3248 04:32:04,623 --> 04:32:05,623 And in this video, first of all, we are going\n 3249 04:32:05,623 --> 04:32:06,623 this add new contact method. In here we are\n 3250 04:32:06,623 --> 04:32:07,623 list. But before that, we need to make sure\n 3251 04:32:07,623 --> 04:32:08,623 saved on our device for that before adding\n 3252 04:32:08,623 --> 04:32:09,623 going to check that if I have such a contact\n 3253 04:32:09,623 --> 04:32:10,623 a Boolean in here. Let's say Boolean does\n 3254 04:32:10,623 --> 04:32:11,623 that, I'm going to create a for each loop.\n 3255 04:32:11,623 --> 04:32:12,623 I have a list. Let's see if c dot get name\n 3256 04:32:12,623 --> 04:32:13,623 Inside this if statement, I'm going to change\n 3257 04:32:13,623 --> 04:32:14,623 say does exist is equal to true. After the\n 3258 04:32:14,623 --> 04:32:15,623 exist is equal to true or not. Let's say if\n 3259 04:32:15,623 --> 04:32:16,623 to print something we are going to say we\n 3260 04:32:16,623 --> 04:32:17,623 we are going to start from the beginning of\n 3261 04:32:17,623 --> 04:32:18,623 new contact method once again. But in the\n 3262 04:32:18,623 --> 04:32:19,623 my account. Tech's ArrayList, so I'm going\n 3263 04:32:19,623 --> 04:32:20,623 going to paste them inside this else case.\n 3264 04:32:20,623 --> 04:32:21,623 array list, I'm going to show some message\n 3265 04:32:21,623 --> 04:32:22,623 Okay, that's the fix that we needed inside\n 3266 04:32:22,623 --> 04:32:23,623 the show all contacts method a little bit\n 3267 04:32:23,623 --> 04:32:24,623 printing the details of a contact, I'm going\n 3268 04:32:24,623 --> 04:32:25,623 to be just a separator that will indicate\n 3269 04:32:25,623 --> 04:32:26,623 Nothing special in here. Okay, let's move\n 3270 04:32:26,623 --> 04:32:27,623 created in here, this manage messages method,\n 3271 04:32:27,623 --> 04:32:28,623 that method. First of all, we are going to\n 3272 04:32:28,623 --> 04:32:29,623 After that, we need to receive the user's\n 3273 04:32:29,623 --> 04:32:30,623 a scanner dot next int. And let's create our\n 3274 04:32:30,623 --> 04:32:31,623 Vaughn, we are going to show a list of all\n 3275 04:32:31,623 --> 04:32:32,623 we will create that method in a minute. But\n 3276 04:32:32,623 --> 04:32:33,623 the other cases. In case it's true, we are\n 3277 04:32:33,623 --> 04:32:34,623 send a new message. And let's add a break.\n 3278 04:32:34,623 --> 04:32:35,623 the initial options. After that, in here,\n 3279 04:32:35,623 --> 04:32:36,623 this show all messages method. In here, first\n 3280 04:32:36,623 --> 04:32:37,623 from all of the contacts into an array list.\n 3281 04:32:37,623 --> 04:32:38,623 Let's name it all messages is equal to new\n 3282 04:32:38,623 --> 04:32:39,623 a for each loop. For contact, see inside my\n 3283 04:32:39,623 --> 04:32:40,623 that at all, we haven't used this add all\n 3284 04:32:40,623 --> 04:32:41,623 I'm going to say C dot get messages. So by\n 3285 04:32:41,623 --> 04:32:42,623 of the messages of one contact to our all\n 3286 04:32:42,623 --> 04:32:43,623 going to check that if the size of these all\n 3287 04:32:43,623 --> 04:32:44,623 messages that size is greater than zero, I'm\n 3288 04:32:44,623 --> 04:32:45,623 So for that, I'm going to create another for\n 3289 04:32:45,623 --> 04:32:46,623 let's name it m inside out all messages, at\n 3290 04:32:46,623 --> 04:32:47,623 after that, let's also print some separator.\n 3291 04:32:47,623 --> 04:32:48,623 you do not have any message. After everything\n 3292 04:32:48,623 --> 04:32:49,623 the initial options. Okay, that's it for this\n 3293 04:32:49,623 --> 04:32:50,623 the other method, which is send a new message.\n 3294 04:32:50,623 --> 04:32:51,623 contact or recipients name. So let's ask the\n 3295 04:32:51,623 --> 04:32:52,623 send a message. After that we need to get\n 3296 04:32:52,623 --> 04:32:53,623 name is equal to scanner dot next. After that,\n 3297 04:32:53,623 --> 04:32:54,623 or not for that, I can say if name that equals\n 3298 04:32:54,623 --> 04:32:55,623 to enter a name. So let's say please enter\n 3299 04:32:55,623 --> 04:32:56,623 going to have a recursive call. So in here,\n 3300 04:32:56,623 --> 04:32:57,623 the else case, I'm going to check that if\n 3301 04:32:57,623 --> 04:32:58,623 For that I'm going to define a Boolean in\n 3302 04:32:58,623 --> 04:32:59,623 After that, I'm going to create a for each\n 3303 04:32:59,623 --> 04:33:00,623 contacts or at least if see that gets name,\n 3304 04:33:00,623 --> 04:33:01,623 Let's say it does exist is equal to true.\n 3305 04:33:01,623 --> 04:33:02,623 if does exist is equal to true or not. First\n 3306 04:33:02,623 --> 04:33:03,623 else case, I'm going to say there is no such\n 3307 04:33:03,623 --> 04:33:04,623 have such a contact, we are going to ask for\n 3308 04:33:04,623 --> 04:33:05,623 you going to say? Let's say a string text\n 3309 04:33:05,623 --> 04:33:06,623 we need to make sure that this text is empty\n 3310 04:33:06,623 --> 04:33:07,623 string. If that's the case, let's say please\nenter some message. 3311 04:33:07,623 --> 04:33:08,623 And after that, we are going to start from\n 3312 04:33:08,623 --> 04:33:09,623 send me a message, which once again is a recursive\n 3313 04:33:09,623 --> 04:33:10,623 create our message object. And after that,\n 3314 04:33:10,623 --> 04:33:11,623 exists in our contacts ArrayList. But if you\n 3315 04:33:11,623 --> 04:33:12,623 a field called ID. Basically, whenever you\n 3316 04:33:12,623 --> 04:33:13,623 or maybe a web server, this ID is unique to\n 3317 04:33:13,623 --> 04:33:14,623 close as I can, and to a real world application.\n 3318 04:33:14,623 --> 04:33:15,623 to have a unique ID for every message, I'm\n 3319 04:33:15,623 --> 04:33:16,623 my main class I am talking about here. And\n 3320 04:33:16,623 --> 04:33:17,623 this ID by one every time that we create a\n 3321 04:33:17,623 --> 04:33:18,623 static integer. Let's name this phone ID.\n 3322 04:33:18,623 --> 04:33:19,623 that down in here, when we create our message\n 3323 04:33:19,623 --> 04:33:20,623 I can say ID plus plus. So because this ID\n 3324 04:33:20,623 --> 04:33:21,623 its value, it's going to be unique for every\n 3325 04:33:21,623 --> 04:33:22,623 our recipient, which we have received above\n 3326 04:33:22,623 --> 04:33:23,623 which is this text. And also we have generated\n 3327 04:33:23,623 --> 04:33:24,623 things that we need in order to create our\n 3328 04:33:24,623 --> 04:33:25,623 it new message is equal to new message we\n 3329 04:33:25,623 --> 04:33:26,623 which is name. And after that, we need the\n 3330 04:33:26,623 --> 04:33:27,623 to add this message to his or her array list\n 3331 04:33:27,623 --> 04:33:28,623 to create a for loop. Let's say for contact\n 3332 04:33:28,623 --> 04:33:29,623 say if see that get name is equal to the name\n 3333 04:33:29,623 --> 04:33:30,623 of all, we need to get the array list of different\n 3334 04:33:30,623 --> 04:33:31,623 array list of messages. Let's call this ArrayList\n 3335 04:33:31,623 --> 04:33:32,623 After that, we need to add this new message\n 3336 04:33:32,623 --> 04:33:33,623 new messages that add new message Sorry, I\n 3337 04:33:33,623 --> 04:33:34,623 this all. After that we are going to save\n 3338 04:33:34,623 --> 04:33:35,623 because later on we are going to remove this\n 3339 04:33:35,623 --> 04:33:36,623 we are going to update his or her array list\n 3340 04:33:36,623 --> 04:33:37,623 to add it once again to our contacts ArrayList.\n 3341 04:33:37,623 --> 04:33:38,623 it current contact is equal to see. Next we\n 3342 04:33:38,623 --> 04:33:39,623 And we need to pass our new messages are released.\n 3343 04:33:39,623 --> 04:33:40,623 our contacts or at least we can say contacts\n 3344 04:33:40,623 --> 04:33:41,623 Now that we have removed the previous contact,\n 3345 04:33:41,623 --> 04:33:42,623 dot add. Let's say current contact. So this\n 3346 04:33:42,623 --> 04:33:43,623 specific contact and we have updated our contacts\n 3347 04:33:43,623 --> 04:33:44,623 we need in order to add a new message just\n 3348 04:33:44,623 --> 04:33:45,623 method. We need to show the initial options\n 3349 04:33:45,623 --> 04:33:46,623 let's see what else do we have? I think we\n 3350 04:33:46,623 --> 04:33:47,623 to test our application. So let's run the\napplication. 3351 04:33:47,623 --> 04:33:48,623 In here we are seeing the greeting message,\n 3352 04:33:48,623 --> 04:33:49,623 initial list of options. If we select one,\n 3353 04:33:49,623 --> 04:33:50,623 contacts. Right now we do not have any contacts\n 3354 04:33:50,623 --> 04:33:51,623 can see that we are not seeing anything, it's\n 3355 04:33:51,623 --> 04:33:52,623 if we do not have any contact in our phone,\n 3356 04:33:52,623 --> 04:33:53,623 contact on your device, but we will write\n 3357 04:33:53,623 --> 04:33:54,623 other options. Once again, let's select Manage\n 3358 04:33:54,623 --> 04:33:55,623 contact, you can see that the console is waiting\n 3359 04:33:55,623 --> 04:33:56,623 is waiting for a number. Let's add some number.\n 3360 04:33:56,623 --> 04:33:57,623 let's say may sam@gmail.com. And as you can\n 3361 04:33:57,623 --> 04:33:58,623 to make sure of that, once again, you can\n 3362 04:33:58,623 --> 04:33:59,623 saying show all contacts. And in here you\n 3363 04:33:59,623 --> 04:34:00,623 another contact. Let's say Sarah, this thing.\n 3364 04:34:00,623 --> 04:34:01,623 This time let's try searching for a new contact.\n 3365 04:34:01,623 --> 04:34:02,623 the console is waiting for the name of our\n 3366 04:34:02,623 --> 04:34:03,623 see that we are seeing this message there\n 3367 04:34:03,623 --> 04:34:04,623 let's try searching for contact this time.\n 3368 04:34:04,623 --> 04:34:05,623 the details about Sarah. Let's also try removing\n 3369 04:34:05,623 --> 04:34:06,623 to delete a contact, let's say me Sam. In\n 3370 04:34:06,623 --> 04:34:07,623 if that we have deleted Maxim successfully\n 3371 04:34:07,623 --> 04:34:08,623 we should see only Sarah. And as you can see,\n 3372 04:34:08,623 --> 04:34:09,623 also try this go back as well. So let's say\n 3373 04:34:09,623 --> 04:34:10,623 put any number beside one through four, for\n 3374 04:34:10,623 --> 04:34:11,623 are going back to the main menu. Also, let's\n 3375 04:34:11,623 --> 04:34:12,623 Sorry about that, I need to go back and select\n 3376 04:34:12,623 --> 04:34:13,623 Let's don't provide anything for the name.\n 3377 04:34:13,623 --> 04:34:14,623 some input. But even if the scanner moves\n 3378 04:34:14,623 --> 04:34:15,623 in order to prevent adding an empty contact.\n 3379 04:34:15,623 --> 04:34:16,623 again. Let's add some number. And some you\n 3380 04:34:16,623 --> 04:34:17,623 option. In order to see a list of all of the\n 3381 04:34:17,623 --> 04:34:18,623 message you don't have any message. Once again,\n 3382 04:34:18,623 --> 04:34:19,623 two in here and let's try sending a new message.\n 3383 04:34:19,623 --> 04:34:20,623 say Sarah, what are you going to say? Let's\n 3384 04:34:20,623 --> 04:34:21,623 crash and the crash happened because of this\n 3385 04:34:21,623 --> 04:34:22,623 Okay, let's take a deeper look into our code.\n 3386 04:34:22,623 --> 04:34:23,623 time. It seems like the exception occurred\n 3387 04:34:23,623 --> 04:34:24,623 you can see the line 99 in here, if you click\n 3388 04:34:24,623 --> 04:34:25,623 Yes, we have this exception inside the add\n 3389 04:34:25,623 --> 04:34:26,623 for loop. I think the error in here is happening\n 3390 04:34:26,623 --> 04:34:27,623 to assign a new value to this current contact.\n 3391 04:34:27,623 --> 04:34:28,623 remove this contact from our contacts ArrayList.\n 3392 04:34:28,623 --> 04:34:29,623 exception. If you want to get over that exception,\n 3393 04:34:29,623 --> 04:34:30,623 in here I'm going to delete all these three\n 3394 04:34:30,623 --> 04:34:31,623 new messages are released. We have added our\n 3395 04:34:31,623 --> 04:34:32,623 in order to update the array list inside this\n 3396 04:34:32,623 --> 04:34:33,623 I can pass my new messages ArrayList. So no\n 3397 04:34:33,623 --> 04:34:34,623 into our ArrayList. concurrently. Let's run\n 3398 04:34:34,623 --> 04:34:35,623 if we are seeing the exception once again.\n 3399 04:34:35,623 --> 04:34:36,623 let's say manage contact, add a new contact.\n 3400 04:34:36,623 --> 04:34:37,623 some email. And now we can send a new message,\n 3401 04:34:37,623 --> 04:34:38,623 are you going to send a message? Let's say\n 3402 04:34:38,623 --> 04:34:39,623 line of code, we got the exception. Let's\n 3403 04:34:39,623 --> 04:34:40,623 have added or we have sent a new message.\n 3404 04:34:40,623 --> 04:34:41,623 go to the messages option. And you can show\n 3405 04:34:41,623 --> 04:34:42,623 see that we have one message in which we have\n 3406 04:34:42,623 --> 04:34:43,623 Once again, let's go to this messages option.\n 3407 04:34:43,623 --> 04:34:44,623 So if I type three or any other number beside\n 3408 04:34:44,623 --> 04:34:45,623 main menu. For example, let's say for and\n 3409 04:34:45,623 --> 04:34:46,623 options. For the last thing, let's try creating\n 3410 04:34:46,623 --> 04:34:47,623 created the application successfully, let's\n 3411 04:34:47,623 --> 04:34:48,623 show all contacts method. If you remember\n 3412 04:34:48,623 --> 04:34:49,623 in case if we don't have any contacts in our\n 3413 04:34:49,623 --> 04:34:50,623 going to check that if we do have any contact.\n 3414 04:34:50,623 --> 04:34:51,623 size is greater than zero. First of all, let's\n 3415 04:34:51,623 --> 04:34:52,623 just going to print you do not have any contact.\n 3416 04:34:52,623 --> 04:34:53,623 same thing that we were doing previously.\n 3417 04:34:53,623 --> 04:34:54,623 order to see that these changes are effective\nor not. 3418 04:34:54,623 --> 04:34:55,623 So right now, we do not have any contacts\n 3419 04:34:55,623 --> 04:34:56,623 why we are losing the contacts that we are\n 3420 04:34:56,623 --> 04:34:57,623 we are not using any permanent data storage\n 3421 04:34:57,623 --> 04:34:58,623 list and that ArrayList will be cleared when\n 3422 04:34:58,623 --> 04:34:59,623 all of the contacts are being removed whenever\n 3423 04:34:59,623 --> 04:35:00,623 contacts. And let's say show all contacts,\n 3424 04:35:00,623 --> 04:35:01,623 have any contacts. But it's better to show\n 3425 04:35:01,623 --> 04:35:02,623 we print this line of code. So down in here\n 3426 04:35:02,623 --> 04:35:03,623 initial options. Okay, this was the last video\n 3427 04:35:03,623 --> 04:35:04,623 for this challenge. Your solution is probably\n 3428 04:35:04,623 --> 04:35:05,623 there are multiple ways of creating the same\n 3429 04:35:05,623 --> 04:35:06,623 and learned everything that we have talked\n 3430 04:35:06,623 --> 04:35:07,623 of the course, we are going to switch back\n 3431 04:35:07,623 --> 04:35:08,623 about user interface and how we can design\n 3432 04:35:08,623 --> 04:35:09,623 you in the next section. What's up everyone,\n 3433 04:35:09,623 --> 04:35:10,623 our talk about user interface, I just wanted\n 3434 04:35:10,623 --> 04:35:11,623 of the scores that you can watch. by enrolling\n 3435 04:35:11,623 --> 04:35:12,623 access to more than 60 hours of videos, you\n 3436 04:35:12,623 --> 04:35:13,623 I will come back to you within hours, you\n 3437 04:35:13,623 --> 04:35:14,623 that I write in the videos. And also you can\n 3438 04:35:14,623 --> 04:35:15,623 I upload. Just check out miko.org for more\n 3439 04:35:15,623 --> 04:35:16,623 to use Free Code Camp as the coupon code to\n 3440 04:35:16,623 --> 04:35:17,623 in Android app development. Taking the extended\n 3441 04:35:17,623 --> 04:35:18,623 I just wanted to remind you that there is\n 3442 04:35:18,623 --> 04:35:19,623 can take without further ado, let's just start\n 3443 04:35:19,623 --> 04:35:20,623 Hello everyone and welcome back. This is the\n 3444 04:35:20,623 --> 04:35:21,623 are going to talk about a lot of concepts\n 3445 04:35:21,623 --> 04:35:22,623 We are going to talk about a lot of UI elements\n 3446 04:35:22,623 --> 04:35:23,623 about different kinds of event listeners,\n 3447 04:35:23,623 --> 04:35:24,623 UI elements. We will talk about how can we\n 3448 04:35:24,623 --> 04:35:25,623 different screen sizes, and also different\n 3449 04:35:25,623 --> 04:35:26,623 about material design and all sorts of stuff\n 3450 04:35:26,623 --> 04:35:27,623 ado, let's jump into our project. And let's\n 3451 04:35:27,623 --> 04:35:28,623 I'm no longer using IntelliJ ID, and I've\n 3452 04:35:28,623 --> 04:35:29,623 ID for the Java section of the course. But\n 3453 04:35:29,623 --> 04:35:30,623 just in case if you forget how to create a\n 3454 04:35:30,623 --> 04:35:31,623 start from scratch. Let's start a new Android\n 3455 04:35:31,623 --> 04:35:32,623 a template. If you remember, I said that these\n 3456 04:35:32,623 --> 04:35:33,623 some level. Later on in the course, specifically,\n 3457 04:35:33,623 --> 04:35:34,623 see that how can we create all of these from\n 3458 04:35:34,623 --> 04:35:35,623 empty activity. After that in here, we needed\n 3459 04:35:35,623 --> 04:35:36,623 application, I'm going to say UI basics. I'm\n 3460 04:35:36,623 --> 04:35:37,623 it's fine. We needed a save location. Once\n 3461 04:35:37,623 --> 04:35:38,623 I'm going to say Java for the minimum API\n 3462 04:35:38,623 --> 04:35:39,623 most videos for this course, I'm going to\n 3463 04:35:39,623 --> 04:35:40,623 of these, let's just create our project by\n 3464 04:35:40,623 --> 04:35:41,623 It seems like our project has been created\n 3465 04:35:41,623 --> 04:35:42,623 let's have another look at this class that\n 3466 04:35:42,623 --> 04:35:43,623 let's minimize this Ron pane. 3467 04:35:43,623 --> 04:35:44,623 As you can see, this is a Java class in our\n 3468 04:35:44,623 --> 04:35:45,623 main activity. This class is extending the\n 3469 04:35:45,623 --> 04:35:46,623 this class, we have this onCreate method which\n 3470 04:35:46,623 --> 04:35:47,623 of this app compat activity. And also above\n 3471 04:35:47,623 --> 04:35:48,623 are importing this app compat activity and\n 3472 04:35:48,623 --> 04:35:49,623 will talk about them later on in the course.\n 3473 04:35:49,623 --> 04:35:50,623 of a simple Java class in here as well. If\n 3474 04:35:50,623 --> 04:35:51,623 activity, a Java class and also XML file will\n 3475 04:35:51,623 --> 04:35:52,623 the behavior of your application. For example,\n 3476 04:35:52,623 --> 04:35:53,623 input in the Java file, you may decide to\n 3477 04:35:53,623 --> 04:35:54,623 now that we know about Java, we can understand\n 3478 04:35:54,623 --> 04:35:55,623 is a part of something called the activity\n 3479 04:35:55,623 --> 04:35:56,623 videos. But for now, just know that this onCreate\n 3480 04:35:56,623 --> 04:35:57,623 a simple Java application. This is the start\n 3481 04:35:57,623 --> 04:35:58,623 our application has only one activity, this\n 3482 04:35:58,623 --> 04:35:59,623 So this line 13 in here would be the start\n 3483 04:35:59,623 --> 04:36:00,623 statement in here. Once again, it means that\n 3484 04:36:00,623 --> 04:36:01,623 class. In this case, the parent class is this\n 3485 04:36:01,623 --> 04:36:02,623 are not concerned about that. But as you can\n 3486 04:36:02,623 --> 04:36:03,623 which is a bonded to the super statement.\n 3487 04:36:03,623 --> 04:36:04,623 important to note that inside activities,\n 3488 04:36:04,623 --> 04:36:05,623 this option in Java. For example, you can\n 3489 04:36:05,623 --> 04:36:06,623 see the declaration of this method anywhere\n 3490 04:36:06,623 --> 04:36:07,623 using it, you are not getting any red warning.\n 3491 04:36:07,623 --> 04:36:08,623 a lot of other inner methods inside an activity,\n 3492 04:36:08,623 --> 04:36:09,623 Okay, let's move on from this part. And let's\n 3493 04:36:09,623 --> 04:36:10,623 wanted to have another look at Our application\n 3494 04:36:10,623 --> 04:36:11,623 know about Java, okay, let's close this java\n 3495 04:36:11,623 --> 04:36:12,623 main dot XML file. If you remember in the\n 3496 04:36:12,623 --> 04:36:13,623 is a markup language. Once again, if you are\n 3497 04:36:13,623 --> 04:36:14,623 languages. Those are just helpful for defining\n 3498 04:36:14,623 --> 04:36:15,623 the user. Before everything. Let's scripting\n 3499 04:36:15,623 --> 04:36:16,623 we are inside the Android view. And if you\n 3500 04:36:16,623 --> 04:36:17,623 you can come to this Resources folder. down\n 3501 04:36:17,623 --> 04:36:18,623 see the file. And if you switch to projects\n 3502 04:36:18,623 --> 04:36:19,623 inside the app folder. Inside the source folder,\n 3503 04:36:19,623 --> 04:36:20,623 have the Resources folder. Once again, inside\n 3504 04:36:20,623 --> 04:36:21,623 dot XML file. Okay, let's switch back to Android\n 3505 04:36:21,623 --> 04:36:22,623 for now, if you remember from the previous\n 3506 04:36:22,623 --> 04:36:23,623 you want to define a layout file, you have\n 3507 04:36:23,623 --> 04:36:24,623 design view for example, by dragging some\n 3508 04:36:24,623 --> 04:36:25,623 You can have different elements and later\n 3509 04:36:25,623 --> 04:36:26,623 elements. This is one way but the other way\n 3510 04:36:26,623 --> 04:36:27,623 everything that you need. In my opinion, when\n 3511 04:36:27,623 --> 04:36:28,623 times you are going to work with the TextView.\n 3512 04:36:28,623 --> 04:36:29,623 TextView. First of all, if you're not seeing\n 3513 04:36:29,623 --> 04:36:30,623 it and disable it from this preview option\n 3514 04:36:30,623 --> 04:36:31,623 suggestion is to disable this review, because\n 3515 04:36:31,623 --> 04:36:32,623 time. And that's going to load a lot of pressures\n 3516 04:36:32,623 --> 04:36:33,623 For that if you have low memory RAM, disable\n 3517 04:36:33,623 --> 04:36:34,623 Right now inside this simple layout file,\n 3518 04:36:34,623 --> 04:36:35,623 I click on this TextView this TextView inside\n 3519 04:36:35,623 --> 04:36:36,623 that these are the same. I'm going to delete\n 3520 04:36:36,623 --> 04:36:37,623 it. And let's press Delete. The next thing\n 3521 04:36:37,623 --> 04:36:38,623 change this constraint layout. In future videos,\n 3522 04:36:38,623 --> 04:36:39,623 is. But for now, for a starter, I think it's\n 3523 04:36:39,623 --> 04:36:40,623 select that. Also, if you have noticed, you\n 3524 04:36:40,623 --> 04:36:41,623 tag in here to relative layout, the closing\n 3525 04:36:41,623 --> 04:36:42,623 well. Inside these opening and closing tags,\n 3526 04:36:42,623 --> 04:36:43,623 if I want to define a TextView, I can open\n 3527 04:36:43,623 --> 04:36:44,623 In capital T, we have a list of options. Let's\n 3528 04:36:44,623 --> 04:36:45,623 after pressing Enter, we are getting some\n 3529 04:36:45,623 --> 04:36:46,623 need at least two attributes a width and also\n 3530 04:36:46,623 --> 04:36:47,623 can be some numbers. But Alternatively, you\n 3531 04:36:47,623 --> 04:36:48,623 as well. We will talk about this match parent\n 3532 04:36:48,623 --> 04:36:49,623 let's just select wrap content. Basically,\n 3533 04:36:49,623 --> 04:36:50,623 view for the height. Let's also select wrap\n 3534 04:36:50,623 --> 04:36:51,623 your text view by adding a slashing here.\n 3535 04:36:51,623 --> 04:36:52,623 if you want to have more attributes, you have\n 3536 04:36:52,623 --> 04:36:53,623 slash I'm going to say let's say text, you\n 3537 04:36:53,623 --> 04:36:54,623 recall that text let's select that. And in\n 3538 04:36:55,623 --> 04:36:56,623 As soon as I type this, you can see that text\n 3539 04:36:56,623 --> 04:36:57,623 the attributes of this text view. Let's talk\n 3540 04:36:57,623 --> 04:36:58,623 For example, right now this text is at the\n 3541 04:36:58,623 --> 04:36:59,623 going to change the position of this TextView\n 3542 04:36:59,623 --> 04:37:00,623 multiple options First of all, I can add some\n 3543 04:37:00,623 --> 04:37:01,623 TextView at the edge of the screen. For example,\n 3544 04:37:01,623 --> 04:37:02,623 50 dP dp is the unit when you're working with\n 3545 04:37:02,623 --> 04:37:03,623 some margin, but we can be more specific for\n 3546 04:37:03,623 --> 04:37:04,623 margin right and also margin bottom. For example,\n 3547 04:37:04,623 --> 04:37:05,623 time, margins are extremely useful but in\n 3548 04:37:05,623 --> 04:37:06,623 this is not accurate, we want our TextView\n 3549 04:37:06,623 --> 04:37:07,623 that, instead of using a margin, I have a\n 3550 04:37:07,623 --> 04:37:08,623 in order to center my text view horizontally.\n 3551 04:37:08,623 --> 04:37:09,623 in here, let's pass through. And this time\n 3552 04:37:09,623 --> 04:37:10,623 If you want, you can also center it vertically\n 3553 04:37:10,623 --> 04:37:11,623 of true, you can see that it has been centered\n 3554 04:37:11,623 --> 04:37:12,623 two, you also have another option. For example,\n 3555 04:37:12,623 --> 04:37:13,623 these attributes. Instead, I'm going to say\n 3556 04:37:13,623 --> 04:37:14,623 pass through as the value of this attribute.\n 3557 04:37:14,623 --> 04:37:15,623 elements inside its parent element. an XML\n 3558 04:37:15,623 --> 04:37:16,623 And above them, we have the parent elements.\n 3559 04:37:16,623 --> 04:37:17,623 is a relative layout. If we want, we can have\n 3560 04:37:17,623 --> 04:37:18,623 other UI elements. And inside that element,\n 3561 04:37:18,623 --> 04:37:19,623 kind of inheritance as many times as we want.\n 3562 04:37:19,623 --> 04:37:20,623 element. And this relative layout is our parent\n 3563 04:37:20,623 --> 04:37:21,623 attribute, it's going to center our TextView\n 3564 04:37:21,623 --> 04:37:22,623 from this part. If you want, you can also\n 3565 04:37:22,623 --> 04:37:23,623 can say text size, this attribute in here,\n 3566 04:37:23,623 --> 04:37:24,623 can say 20 SB. When you're working with the\n 3567 04:37:24,623 --> 04:37:25,623 see that it's larger now. Also, if you want\n 3568 04:37:25,623 --> 04:37:26,623 For that we can say text style. This attribute\n 3569 04:37:26,623 --> 04:37:27,623 normal. For example, let's fast bold. If you\n 3570 04:37:27,623 --> 04:37:28,623 you can add a pipeline in here. And after\n 3571 04:37:28,623 --> 04:37:29,623 see both of these attributes in the same element.\n 3572 04:37:29,623 --> 04:37:30,623 of your text for that we can say text color.\n 3573 04:37:30,623 --> 04:37:31,623 be defined inside another XML file called\n 3574 04:37:31,623 --> 04:37:32,623 color, accent, color, primary and color primary\n 3575 04:37:32,623 --> 04:37:33,623 corners. Let's select the first one. And as\n 3576 04:37:33,623 --> 04:37:34,623 But where does this color dot XML file locates\n 3577 04:37:34,623 --> 04:37:35,623 a look at that, you can open the project pane.\n 3578 04:37:35,623 --> 04:37:36,623 folder, we have this colors dot XML, you can\n 3579 04:37:36,623 --> 04:37:37,623 the exact name that we just saw. Don't worry\n 3580 04:37:37,623 --> 04:37:38,623 kinds of XML files in future videos. But for\n 3581 04:37:38,623 --> 04:37:39,623 So instead of passing a color from inside\n 3582 04:37:39,623 --> 04:37:40,623 the hexadecimal value of that color. For that\n 3583 04:37:41,623 --> 04:37:42,623 Let's search that. For example. Let's select\n 3584 04:37:42,623 --> 04:37:43,623 in here, you can see the hexadecimal value.\n 3585 04:37:43,623 --> 04:37:44,623 from inside our color dot XML file, I'm going\n 3586 04:37:44,623 --> 04:37:45,623 see that the color of the TextView has been\n 3587 04:37:45,623 --> 04:37:46,623 If you remember from the previous videos of\n 3588 04:37:46,623 --> 04:37:47,623 to have access to all of these UI elements\n 3589 04:37:47,623 --> 04:37:48,623 add an ID attribute for this TextView as well,\n 3590 04:37:48,623 --> 04:37:49,623 plus ID slash. Let's select that. And let's\n 3591 04:37:49,623 --> 04:37:50,623 ID attribute should be unique inside every\n 3592 04:37:50,623 --> 04:37:51,623 inside the same XML file cannot have the same\n 3593 04:37:51,623 --> 04:37:52,623 file in order to have access to this TextView\n 3594 04:37:52,623 --> 04:37:53,623 but I think if we continue we are going to\n 3595 04:37:53,623 --> 04:37:54,623 this TextView. And I'm going to define a button\n 3596 04:37:54,623 --> 04:37:55,623 I can open an anchor bracket. And in here\n 3597 04:37:55,623 --> 04:37:56,623 select the first option. Once again, we have\n 3598 04:37:56,623 --> 04:37:57,623 let's talk about the difference between this\n 3599 04:37:57,623 --> 04:37:58,623 I select match parent, let's also select match\n 3600 04:37:58,623 --> 04:37:59,623 button is covering all of this screen. And\n 3601 04:37:59,623 --> 04:38:00,623 to match parent. If you want, you can change\n 3602 04:38:00,623 --> 04:38:01,623 here you can see the difference the width\n 3603 04:38:01,623 --> 04:38:02,623 the buttons content. Let's also change the\n 3604 04:38:02,623 --> 04:38:03,623 and match parent, you can always pass the\n 3605 04:38:03,623 --> 04:38:04,623 DPI, you can see that the width has been changed.\n 3606 04:38:04,623 --> 04:38:05,623 application is going to be installed on devices\n 3607 04:38:05,623 --> 04:38:06,623 we put some numbers for these, if we pass\n 3608 04:38:06,623 --> 04:38:07,623 position of every element. And also sometimes\n 3609 04:38:07,623 --> 04:38:08,623 some devices. So for that matter, I'm going\n 3610 04:38:08,623 --> 04:38:09,623 Also, now that I have talked about different\n 3611 04:38:09,623 --> 04:38:10,623 inside this preview, you have this option\n 3612 04:38:10,623 --> 04:38:11,623 that, you can see a drop down. And from here,\n 3613 04:38:11,623 --> 04:38:12,623 example, let's select this font, and you can\n 3614 04:38:12,623 --> 04:38:13,623 screen sizes. For example, let's take a tablet,\n 3615 04:38:13,623 --> 04:38:14,623 worry about this. Later on in the course we\n 3616 04:38:14,623 --> 04:38:15,623 look for our application in different screen\n 3617 04:38:15,623 --> 04:38:16,623 above in here. Like for the text view, we\n 3618 04:38:16,623 --> 04:38:17,623 Let's say text. And let's say Say hello. Similarly,\n 3619 04:38:17,623 --> 04:38:18,623 I'm not going to do that right now. Instead,\n 3620 04:38:18,623 --> 04:38:19,623 TextView. For that we have an attribute called\n 3621 04:38:19,623 --> 04:38:20,623 need to pass the ID of the other element.\n 3622 04:38:20,623 --> 04:38:21,623 the ID of this TextView I can say at plus\n 3623 04:38:21,623 --> 04:38:22,623 see that the button has been moved to below\n 3624 04:38:22,623 --> 04:38:23,623 we want, we also need to center it horizontally.\n 3625 04:38:23,623 --> 04:38:24,623 and we can pass through. Let's also add a\nmargin top. 3626 04:38:24,623 --> 04:38:25,623 Let's say margin top. And let's pass for example\n 3627 04:38:25,623 --> 04:38:26,623 texts here and button you have another attribute\n 3628 04:38:26,623 --> 04:38:27,623 can say background. And for example, we can\n 3629 04:38:27,623 --> 04:38:28,623 you can see that the background color of this\n 3630 04:38:28,623 --> 04:38:29,623 the same option for the TextView. If you want\n 3631 04:38:29,623 --> 04:38:30,623 color. So I'm going to change that. Let's\n 3632 04:38:30,623 --> 04:38:31,623 dark. Nope, this is not my color. Okay, this\n 3633 04:38:31,623 --> 04:38:32,623 value of the color that you want in here as\n 3634 04:38:32,623 --> 04:38:33,623 another attribute called on click we have\n 3635 04:38:33,623 --> 04:38:34,623 created our first Android application, you\n 3636 04:38:34,623 --> 04:38:35,623 listener for this button and we are going\n 3637 04:38:35,623 --> 04:38:36,623 button. So let's say on click, and let's pass\n 3638 04:38:36,623 --> 04:38:37,623 going to see on Hello btn clicked. Right now\n 3639 04:38:37,623 --> 04:38:38,623 and that's because we need to create this\n 3640 04:38:38,623 --> 04:38:39,623 creating our button by using this slash. And\n 3641 04:38:39,623 --> 04:38:40,623 dot java file. So let's open that file. In\n 3642 04:38:40,623 --> 04:38:41,623 to this project thing. Or alternatively I\n 3643 04:38:41,623 --> 04:38:42,623 see that when I do that I have a search menu.\n 3644 04:38:42,623 --> 04:38:43,623 activity. And if I press Enter on the first\n 3645 04:38:43,623 --> 04:38:44,623 java file. This is just a helpful shortcut\n 3646 04:38:44,623 --> 04:38:45,623 need to create the onClick method inside the\n 3647 04:38:45,623 --> 04:38:46,623 of this onCreate method. If you remember the\n 3648 04:38:46,623 --> 04:38:47,623 like this, we needed to set the access modifier\n 3649 04:38:47,623 --> 04:38:48,623 of the method is going to be exactly the name\n 3650 04:38:48,623 --> 04:38:49,623 say on Hello btn clicked. For the inputs of\n 3651 04:38:49,623 --> 04:38:50,623 object with capital V. This view object is\n 3652 04:38:50,623 --> 04:38:51,623 that we need to receive it as the input of\n 3653 04:38:51,623 --> 04:38:52,623 this input. And in here, we can have the logic\n 3654 04:38:52,623 --> 04:38:53,623 Also, if you have noticed, when I added this\n 3655 04:38:53,623 --> 04:38:54,623 in here, let's also minimize these imports\n 3656 04:38:54,623 --> 04:38:55,623 listeners for buttons. And also for that matter\n 3657 04:38:55,623 --> 04:38:56,623 in which may be more useful from time to time.\n 3658 04:38:56,623 --> 04:38:57,623 in here, let's quickly write some logic. For\n 3659 04:38:57,623 --> 04:38:58,623 text of my text view. For that, first of all,\n 3660 04:38:58,623 --> 04:38:59,623 say text view, if you take a look at your\n 3661 04:38:59,623 --> 04:39:00,623 the widget package has been added to our class.\n 3662 04:39:00,623 --> 04:39:01,623 every UI element. You have a class in Java.\n 3663 04:39:01,623 --> 04:39:02,623 And let's initialize it, we can initialize\n 3664 04:39:02,623 --> 04:39:03,623 this set content view method, this find view\n 3665 04:39:03,623 --> 04:39:04,623 every activity. Right now this find view by\n 3666 04:39:04,623 --> 04:39:05,623 the integer is going to be the ID of our elements.\n 3667 04:39:05,623 --> 04:39:06,623 we can say our.id. Once again, if you remember,\n 3668 04:39:06,623 --> 04:39:07,623 It's a special class in Java, and it will\n 3669 04:39:07,623 --> 04:39:08,623 in our project. So in here, I can say our.id\n 3670 04:39:08,623 --> 04:39:09,623 was txt. Welcome, I believe now that we have\n 3671 04:39:09,623 --> 04:39:10,623 operation on that. For example, I can say\n 3672 04:39:10,623 --> 04:39:11,623 this method previously. And inside this method,\n 3673 04:39:11,623 --> 04:39:12,623 Let's run the application. And let's see if\n 3674 04:39:12,623 --> 04:39:13,623 going to run the application on pixel three\n 3675 04:39:13,623 --> 04:39:14,623 that you want. Okay, right now we can see\n 3676 04:39:14,623 --> 04:39:15,623 is honestly oddly, but don't worry about that\n 3677 04:39:15,623 --> 04:39:16,623 If I click on this button, you can expect\n 3678 04:39:16,623 --> 04:39:17,623 text from hello to Hello again. Okay, there\n 3679 04:39:17,623 --> 04:39:18,623 wanted you to have another look at what we\n 3680 04:39:18,623 --> 04:39:19,623 which was to create your first Android application,\n 3681 04:39:19,623 --> 04:39:20,623 on what you have done in that video. Also,\n 3682 04:39:20,623 --> 04:39:21,623 in here as well. Okay, in the next video,\n 3683 04:39:21,623 --> 04:39:22,623 UI elements. For example, we will talk about\n 3684 04:39:22,623 --> 04:39:23,623 ways that we can implement an onclicklistener\n 3685 04:39:23,623 --> 04:39:24,623 video. In the previous video, we have seen\n 3686 04:39:24,623 --> 04:39:25,623 our button. There are two more ways and in\n 3687 04:39:25,623 --> 04:39:26,623 in our layout file, let's quickly create a\n 3688 04:39:26,623 --> 04:39:27,623 this constraint layout to a relative layout.\n 3689 04:39:27,623 --> 04:39:28,623 button. That's a wrap content and wrap content\n 3690 04:39:28,623 --> 04:39:29,623 For example, let's say Say hello once again.\n 3691 04:39:29,623 --> 04:39:30,623 through, we have seen these in the previous\n 3692 04:39:30,623 --> 04:39:31,623 if you're going to need an ID, let's say btn.\n 3693 04:39:31,623 --> 04:39:32,623 in the previous video, when we wanted to create\n 3694 04:39:32,623 --> 04:39:33,623 onClick attribute. In here, we need to pass\n 3695 04:39:33,623 --> 04:39:34,623 Java file. But in this case, I'm going to\n 3696 04:39:34,623 --> 04:39:35,623 to delete this attribute. Okay, let's switch\n 3697 04:39:35,623 --> 04:39:36,623 button. Inside my onCreate method, I'm going\n 3698 04:39:36,623 --> 04:39:37,623 equal to find view by ID dot btn. Hello. For\n 3699 04:39:37,623 --> 04:39:38,623 you can use the equivalent method you can\n 3700 04:39:38,623 --> 04:39:39,623 can see that we have this method inside the\n 3701 04:39:39,623 --> 04:39:40,623 In this case it can be new view dot onclicklistener.\n 3702 04:39:40,623 --> 04:39:41,623 this is an interface. Okay, now that I have\n 3703 04:39:41,623 --> 04:39:42,623 method has been overrided. And inside this\n 3704 04:39:42,623 --> 04:39:43,623 if I want to print something into my console,\n 3705 04:39:43,623 --> 04:39:44,623 run the application. And let's see if we can\n 3706 04:39:44,623 --> 04:39:45,623 here and if I click on this say hello button,\n 3707 04:39:45,623 --> 04:39:46,623 here. So this way, by using this set onclicklistener\n 3708 04:39:46,623 --> 04:39:47,623 listener. Inside the parentheses of this method,\n 3709 04:39:47,623 --> 04:39:48,623 method. But there is also another way, let's\n 3710 04:39:48,623 --> 04:39:49,623 new interface in here, I'm going to implement\n 3711 04:39:49,623 --> 04:39:50,623 my class. If you remember from the Java session,\n 3712 04:39:50,623 --> 04:39:51,623 can say implement, let's say onClick listener.\n 3713 04:39:51,623 --> 04:39:52,623 is coming from Android dot view that view\n 3714 04:39:52,623 --> 04:39:53,623 we need the first one. When we implement interfaces,\n 3715 04:39:53,623 --> 04:39:54,623 can do that by pressing Ctrl plus by we need\n 3716 04:39:54,623 --> 04:39:55,623 of this onClick method, we are getting a view\nobject. 3717 04:39:55,623 --> 04:39:56,623 And now we can use this view in order to create\n 3718 04:39:56,623 --> 04:39:57,623 on view, or V in this case, it's his name.\n 3719 04:39:57,623 --> 04:39:58,623 our switch depending on the ID of this view\n 3720 04:39:58,623 --> 04:39:59,623 case it's our.id dot btn. Hello, the exact\n 3721 04:39:59,623 --> 04:40:00,623 is the ID let's write some code. For example,\n 3722 04:40:00,623 --> 04:40:01,623 Let's also add a break and also a default\n 3723 04:40:01,623 --> 04:40:02,623 at the declaration of point class, and also\n 3724 04:40:02,623 --> 04:40:03,623 remove this btn hollow dot set onclicklistener\n 3725 04:40:03,623 --> 04:40:04,623 btn Hello dot set onclicklistener. This time\n 3726 04:40:04,623 --> 04:40:05,623 I can say this. If you remember from the Java\n 3727 04:40:05,623 --> 04:40:06,623 Right now we are inside this class which implements\n 3728 04:40:06,623 --> 04:40:07,623 is happy with accepting this as the input.\n 3729 04:40:07,623 --> 04:40:08,623 of all, we are setting the onclicklistener\n 3730 04:40:08,623 --> 04:40:09,623 interface. Whenever the user clicks on this\n 3731 04:40:09,623 --> 04:40:10,623 a view will be passed to this method in this\n 3732 04:40:10,623 --> 04:40:11,623 that why a view and a button are equivalent.\n 3733 04:40:11,623 --> 04:40:12,623 are creating a switch statement. In case the\n 3734 04:40:12,623 --> 04:40:13,623 ID of our button. We are printing this Hello\n 3735 04:40:13,623 --> 04:40:14,623 matter other views, we can create different\n 3736 04:40:14,623 --> 04:40:15,623 the application once again and let's see if\n 3737 04:40:15,623 --> 04:40:16,623 I click on this say hello bata we can see\n 3738 04:40:16,623 --> 04:40:17,623 Also, I don't like to come down in here inside\n 3739 04:40:17,623 --> 04:40:18,623 means that I'm going to show something to\n 3740 04:40:18,623 --> 04:40:19,623 of using this system dot out dot print line,\n 3741 04:40:19,623 --> 04:40:20,623 messages. Let's search for those messages.\n 3742 04:40:20,623 --> 04:40:21,623 a toast message is something like this. This\n 3743 04:40:21,623 --> 04:40:22,623 disappear after a period of time. Let's quickly\n 3744 04:40:22,623 --> 04:40:23,623 So in here, I'm going to delete this line\n 3745 04:40:23,623 --> 04:40:24,623 you can see that I have two options in here.\n 3746 04:40:24,623 --> 04:40:25,623 one is a template. Basically, templates are\n 3747 04:40:25,623 --> 04:40:26,623 example, in here, if I select this template,\n 3748 04:40:26,623 --> 04:40:27,623 been created. So we are using this test class\n 3749 04:40:27,623 --> 04:40:28,623 static method, we are passing a context whatever\n 3750 04:40:28,623 --> 04:40:29,623 on in the course. But for now, so we are using\n 3751 04:40:29,623 --> 04:40:30,623 called make text, we have three inputs for\n 3752 04:40:30,623 --> 04:40:31,623 don't worry about the context yet. We will\n 3753 04:40:31,623 --> 04:40:32,623 for now, just know that every activity in\n 3754 04:40:32,623 --> 04:40:33,623 we are inside an activity, we can pass this\n 3755 04:40:33,623 --> 04:40:34,623 Basically, this is going to be the text that\n 3756 04:40:35,623 --> 04:40:36,623 After that, we have this constant in here,\n 3757 04:40:36,623 --> 04:40:37,623 this is just a constant for determining how\n 3758 04:40:37,623 --> 04:40:38,623 if you want to see the other time periods,\n 3759 04:40:38,623 --> 04:40:39,623 short. Let's select length short. And after\n 3760 04:40:39,623 --> 04:40:40,623 method, which you can guess is going to show\n 3761 04:40:40,623 --> 04:40:41,623 created our toast message. And after that,\n 3762 04:40:41,623 --> 04:40:42,623 showing it to the user. In here we have used\n 3763 04:40:42,623 --> 04:40:43,623 the template, you can always create your own\n 3764 04:40:43,623 --> 04:40:44,623 let's select the first one. Let's say make\n 3765 04:40:44,623 --> 04:40:45,623 the text in here, let's say second text. And\n 3766 04:40:45,623 --> 04:40:46,623 toast that last long dot show. Basically,\n 3767 04:40:46,623 --> 04:40:47,623 can't create them with the help of the ID.\n 3768 04:40:47,623 --> 04:40:48,623 And let's see what would be the result. So\n 3769 04:40:48,623 --> 04:40:49,623 butter, you can see that some toast message\n 3770 04:40:49,623 --> 04:40:50,623 it will be disappeared. I think those messages\n 3771 04:40:50,623 --> 04:40:51,623 It's much better than this round pain down\n 3772 04:40:51,623 --> 04:40:52,623 in here. And let's talk about this view that\n 3773 04:40:52,623 --> 04:40:53,623 Instead of this view, we need to receive a\n 3774 04:40:53,623 --> 04:40:54,623 statement based on the ID of our button. But\n 3775 04:40:54,623 --> 04:40:55,623 the control key. And if you click on this\n 3776 04:40:55,623 --> 04:40:56,623 the CTRL key and if you click on the class\n 3777 04:40:56,623 --> 04:40:57,623 this text view, you can see that this text\n 3778 04:40:57,623 --> 04:40:58,623 means that after two times of inheritance,\n 3779 04:40:58,623 --> 04:40:59,623 the view class two times. So at the end, a\n 3780 04:40:59,623 --> 04:41:00,623 Java session when we have talked about inheritance.\n 3781 04:41:00,623 --> 04:41:01,623 and we created our dog class, we said that\n 3782 04:41:01,623 --> 04:41:02,623 is also a view. For that matter. Every UI\n 3783 04:41:02,623 --> 04:41:03,623 and also other UI elements that we will talk\n 3784 04:41:03,623 --> 04:41:04,623 proves that we can create an onclicklistener\n 3785 04:41:04,623 --> 04:41:05,623 well. So this onClick method is not limited\n 3786 04:41:05,623 --> 04:41:06,623 that when you create your own listener this\n 3787 04:41:06,623 --> 04:41:07,623 class declaration, you just need to create\n 3788 04:41:07,623 --> 04:41:08,623 For example, if I had another method down\n 3789 04:41:08,623 --> 04:41:09,623 button to another case. And inside that case,\n 3790 04:41:09,623 --> 04:41:10,623 as many methods and for that matter, as many\n 3791 04:41:10,623 --> 04:41:11,623 this onClick listener is one of the available\n 3792 04:41:11,623 --> 04:41:12,623 if you want, you can take a look at them by\n 3793 04:41:12,623 --> 04:41:13,623 And you can see a lot of these options we\n 3794 04:41:13,623 --> 04:41:14,623 you can guess the meaning of each one of these,\n 3795 04:41:14,623 --> 04:41:15,623 hover over our button, we also have another\n 3796 04:41:15,623 --> 04:41:16,623 that if we like press on a button, that's\n 3797 04:41:16,623 --> 04:41:17,623 of implementing the on long click listener\n 3798 04:41:17,623 --> 04:41:18,623 the easier way by saying new view dot online\nclick listener. 3799 04:41:18,623 --> 04:41:19,623 This one, you can see that in here we have\n 3800 04:41:19,623 --> 04:41:20,623 click method. This Boolean is just the callback\n 3801 04:41:20,623 --> 04:41:21,623 If you want your code inside this method to\n 3802 04:41:21,623 --> 04:41:22,623 write some logic. In here. For example, I'm\n 3803 04:41:22,623 --> 04:41:23,623 this context in here. But the format is somehow\n 3804 04:41:23,623 --> 04:41:24,623 an interface, we are inside this online click\n 3805 04:41:24,623 --> 04:41:25,623 will refer to the current object, which in\n 3806 04:41:25,623 --> 04:41:26,623 are not context. And we need to pass our activity.\n 3807 04:41:26,623 --> 04:41:27,623 dot this, don't worry about this main activity\n 3808 04:41:27,623 --> 04:41:28,623 about that later on in the course when we\n 3809 04:41:28,623 --> 04:41:29,623 just let's pass this as our context. And let's\n 3810 04:41:29,623 --> 04:41:30,623 period in here to Lance long. I think I need\n 3811 04:41:30,623 --> 04:41:31,623 let's run the application. So like before,\n 3812 04:41:31,623 --> 04:41:32,623 we are seeing this message Hello button clicked,\n 3813 04:41:32,623 --> 04:41:33,623 button. But if I press my button and hold\n 3814 04:41:33,623 --> 04:41:34,623 long press message. So this time, instead\n 3815 04:41:34,623 --> 04:41:35,623 online click listener method. You can also\n 3816 04:41:35,623 --> 04:41:36,623 items. Later on in the course we will check\n 3817 04:41:36,623 --> 04:41:37,623 say btn Hello dot set listener. And you can\n 3818 04:41:37,623 --> 04:41:38,623 let's move on from the event listeners. And\n 3819 04:41:38,623 --> 04:41:39,623 file. Before this button, I am going to define\n 3820 04:41:39,623 --> 04:41:40,623 width, that's a match fine this time. And\n 3821 04:41:40,623 --> 04:41:41,623 can see that it's something like this, if\n 3822 04:41:41,623 --> 04:41:42,623 also add a text in here. Let's say name and\n 3823 04:41:42,623 --> 04:41:43,623 Let's also center our edit text, I'm going\n 3824 04:41:43,623 --> 04:41:44,623 pass through. But right now we have a conflict\n 3825 04:41:44,623 --> 04:41:45,623 that I'm going to move this button to below\n 3826 04:41:45,623 --> 04:41:46,623 give an ID to this edit text. Let's say ID.\n 3827 04:41:46,623 --> 04:41:47,623 creating this edit text. And then in here\n 3828 04:41:47,623 --> 04:41:48,623 or to be a specific layout below. And I can\n 3829 04:41:48,623 --> 04:41:49,623 need this ad plus ID slash. That's the Edit\n 3830 04:41:49,623 --> 04:41:50,623 button to below our edit text. I think it's\n 3831 04:41:50,623 --> 04:41:51,623 top. And let's pass 20 dP, that seems better.\n 3832 04:41:51,623 --> 04:41:52,623 I don't like the text inside my edit text.\n 3833 04:41:52,623 --> 04:41:53,623 try to type something in here, first of all\n 3834 04:41:53,623 --> 04:41:54,623 of this text attribute. I'm going to use another\n 3835 04:41:54,623 --> 04:41:55,623 at the first videos of this course. Let's\n 3836 04:41:55,623 --> 04:41:56,623 So whenever I click on this edit text, and\n 3837 04:41:56,623 --> 04:41:57,623 be disappeared. Also, if we want to decrease\n 3838 04:41:57,623 --> 04:41:58,623 number in here, for example, we can say 250\n 3839 04:41:58,623 --> 04:41:59,623 remember I said that it's never a good idea\n 3840 04:41:59,623 --> 04:42:00,623 in different screen sizes, you cannot predict\n 3841 04:42:00,623 --> 04:42:01,623 once again, I'm going to change this font\n 3842 04:42:01,623 --> 04:42:02,623 that's done in here, I'm going to add two\n 3843 04:42:02,623 --> 04:42:03,623 example, I think it's better to change it\n 3844 04:42:04,623 --> 04:42:05,623 Adding different margins is one way but we\n 3845 04:42:05,623 --> 04:42:06,623 as well. So I'm going to delete both of these\n 3846 04:42:06,623 --> 04:42:07,623 relative layout inside the opening tag. As\n 3847 04:42:07,623 --> 04:42:08,623 this is our opening tag. Inside the opening\n 3848 04:42:08,623 --> 04:42:09,623 once again, like margins, and we have multiple\n 3849 04:42:09,623 --> 04:42:10,623 right top, let's just use padding in here.\n 3850 04:42:10,623 --> 04:42:11,623 the size of our edit text has been changed,\n 3851 04:42:11,623 --> 04:42:12,623 each other. Just there is one difference.\n 3852 04:42:12,623 --> 04:42:13,623 in the previous case, for our edit text, the\n 3853 04:42:13,623 --> 04:42:14,623 element, for example, from here to the end\n 3854 04:42:14,623 --> 04:42:15,623 depth padding, we'll add some space from inside\n 3855 04:42:15,623 --> 04:42:16,623 element is this relative layout itself. And\n 3856 04:42:16,623 --> 04:42:17,623 relative layout. So once again, margin adds\n 3857 04:42:17,623 --> 04:42:18,623 but the padding will add the space from the\n 3858 04:42:18,623 --> 04:42:19,623 them depending on your need. Let's see what\n 3859 04:42:19,623 --> 04:42:20,623 like a TextView, we can change the color for\n 3860 04:42:20,623 --> 04:42:21,623 say text color. And let's pass this color\n 3861 04:42:21,623 --> 04:42:22,623 now we do not have any text inside our edit\n 3862 04:42:22,623 --> 04:42:23,623 color will be changed to this color that we\n 3863 04:42:23,623 --> 04:42:24,623 by saying text style this one, we can say\n 3864 04:42:24,623 --> 04:42:25,623 sides at the same time, we can add a pipeline.\n 3865 04:42:25,623 --> 04:42:26,623 have in text views. And that's called lines.\n 3866 04:42:26,623 --> 04:42:27,623 need a bigger input from the user, you can\n 3867 04:42:27,623 --> 04:42:28,623 if I say four, for example, now our edit text\n 3868 04:42:28,623 --> 04:42:29,623 this case, I'm not going to use these lines.\n 3869 04:42:29,623 --> 04:42:30,623 number for different lines is one. With edit\n 3870 04:42:30,623 --> 04:42:31,623 that you're going to receive. For that you\n 3871 04:42:31,623 --> 04:42:32,623 one of these for example, if it's a date that\n 3872 04:42:32,623 --> 04:42:33,623 maybe this date time. If I'm going to receive\n 3873 04:42:33,623 --> 04:42:34,623 password. If it's just a simple text, I can\n 3874 04:42:34,623 --> 04:42:35,623 example, for different emails, and all sorts\n 3875 04:42:35,623 --> 04:42:36,623 if I select this text password in here, and\n 3876 04:42:36,623 --> 04:42:37,623 say text. You can see that when I typed the\n 3877 04:42:37,623 --> 04:42:38,623 you have seen this on your phone when you\n 3878 04:42:38,623 --> 04:42:39,623 some website, this will add some level of\n 3879 04:42:39,623 --> 04:42:40,623 this text email address when the user clicks\n 3880 04:42:40,623 --> 04:42:41,623 to type the email address. I'm not going to\n 3881 04:42:41,623 --> 04:42:42,623 to delete this one in here as well. And let's\n 3882 04:42:42,623 --> 04:42:43,623 that's enough about edit text. We have all\n 3883 04:42:43,623 --> 04:42:44,623 check them from here. As you can see, there\n 3884 04:42:44,623 --> 04:42:45,623 this button. Let's also define a TextView.\n 3885 04:42:45,623 --> 04:42:46,623 wrap content. Let's give it an ID, let's say.\n 3886 04:42:46,623 --> 04:42:47,623 text. Let's just say hello. Let's also move\n 3887 04:42:47,623 --> 04:42:48,623 layout below. Also, it's worth noticing that\n 3888 04:42:48,623 --> 04:42:49,623 example, if you're using a constraint layout,\n 3889 04:42:49,623 --> 04:42:50,623 This is one of the features of this relative\n 3890 04:42:50,623 --> 04:42:51,623 videos. Okay, in here, let's pass the idea\n 3891 04:42:51,623 --> 04:42:52,623 let's move it to center horizontal. 3892 04:42:52,623 --> 04:42:53,623 And let's add some margins. Margin top of\n 3893 04:42:53,623 --> 04:42:54,623 text by saying text size. And by passing I\n 3894 04:42:54,623 --> 04:42:55,623 with this layout file. Let's just go top in\n 3895 04:42:55,623 --> 04:42:56,623 reformat code in order to rearrange our code\n 3896 04:42:56,623 --> 04:42:57,623 the same code that I'm writing in here. Okay,\n 3897 04:42:57,623 --> 04:42:58,623 define all these three items. Let's say Edit\n 3898 04:42:58,623 --> 04:42:59,623 was name is equal to find view by ID r.id\n 3899 04:42:59,623 --> 04:43:00,623 text view. Let's name it txt name is equal\n 3900 04:43:00,623 --> 04:43:01,623 was it I think it's better to change the name\n 3901 04:43:01,623 --> 04:43:02,623 with our code. We are instantiating our UI\n 3902 04:43:02,623 --> 04:43:03,623 once again is the starting point of our application.\n 3903 04:43:03,623 --> 04:43:04,623 inside this onClick method. Because we are\n 3904 04:43:04,623 --> 04:43:05,623 whenever the user clicks on our button. And\n 3905 04:43:05,623 --> 04:43:06,623 for example, from inside this method, if I\n 3906 04:43:06,623 --> 04:43:07,623 a red warning, you can see that the ID cannot\n 3907 04:43:07,623 --> 04:43:08,623 this method, we do not have access to this\n 3908 04:43:08,623 --> 04:43:09,623 in the Java section. But the problem in here\n 3909 04:43:09,623 --> 04:43:10,623 So right now the scope of this TextView is\n 3910 04:43:10,623 --> 04:43:11,623 that we cannot use that if we want to have\n 3911 04:43:11,623 --> 04:43:12,623 methods, we can say something like this, we\n 3912 04:43:12,623 --> 04:43:13,623 of our class as different fields. For example,\n 3913 04:43:13,623 --> 04:43:14,623 TextView this one. And let's name it. txt\n 3914 04:43:14,623 --> 04:43:15,623 instantiate my TextView, for example, if I\n 3915 04:43:15,623 --> 04:43:16,623 this part in here is not a part of this activity\n 3916 04:43:16,623 --> 04:43:17,623 our TextView at all, we need to instantiate\n 3917 04:43:17,623 --> 04:43:18,623 is once again the starting point of our application.\n 3918 04:43:18,623 --> 04:43:19,623 and instantiating of our UI element, I can\n 3919 04:43:19,623 --> 04:43:20,623 instead of defining the whole TextView I can\n 3920 04:43:20,623 --> 04:43:21,623 is equal to find view by ID r.id dot txt Hello.\n 3921 04:43:21,623 --> 04:43:22,623 a field, I can use it in both of these methods.\n 3922 04:43:22,623 --> 04:43:23,623 dot txt. Inside the set text method, I'm going\n 3923 04:43:23,623 --> 04:43:24,623 I'm going to define this edit text as a field\n 3924 04:43:24,623 --> 04:43:25,623 name it really txt name. And then in here,\n 3925 04:43:25,623 --> 04:43:26,623 this edit text for example to the set text\n 3926 04:43:26,623 --> 04:43:27,623 dot get text. If you remember from the first\n 3927 04:43:27,623 --> 04:43:28,623 a two string method as well. We have seen\n 3928 04:43:28,623 --> 04:43:29,623 It's just going to generate some text. In\n 3929 04:43:29,623 --> 04:43:30,623 if we just pass this edit text name that get\n 3930 04:43:30,623 --> 04:43:31,623 you hover over this get text method you can\n 3931 04:43:31,623 --> 04:43:32,623 is an editable. We do not know what that is\n 3932 04:43:32,623 --> 04:43:33,623 and in here, we are going to need a string.\n 3933 04:43:33,623 --> 04:43:34,623 we need to convert the editable to a string.\n 3934 04:43:34,623 --> 04:43:35,623 I think after a lot of talking, our application\n 3935 04:43:35,623 --> 04:43:36,623 And let's see if we can see the behavior that\n 3936 04:43:36,623 --> 04:43:37,623 say Mesa. And let's press this pattern alone\n 3937 04:43:37,623 --> 04:43:38,623 And hopefully, we understand each piece of\n 3938 04:43:38,623 --> 04:43:39,623 earlier, I said that different UI elements\n 3939 04:43:39,623 --> 04:43:40,623 this button, that's also check the case for\n 3940 04:43:40,623 --> 04:43:41,623 the control key, and you can click on this\n 3941 04:43:41,623 --> 04:43:42,623 the text view, if you click on this text view,\n 3942 04:43:42,623 --> 04:43:43,623 you can see that it's extending the view class.\n 3943 04:43:43,623 --> 04:43:44,623 If you press down the control key, and if\n 3944 04:43:44,623 --> 04:43:45,623 it's extending the view class. Now that we\n 3945 04:43:45,623 --> 04:43:46,623 class, we can create an onclicklistener for\n 3946 04:43:46,623 --> 04:43:47,623 onClick method. If you want, we can create\n 3947 04:43:47,623 --> 04:43:48,623 down in here, for the edit text, I can say\n 3948 04:43:48,623 --> 04:43:49,623 can see that we have this option in here.\n 3949 04:43:49,623 --> 04:43:50,623 interface inside our class declaration, I\n 3950 04:43:50,623 --> 04:43:51,623 onClick method, I can create another case.\n 3951 04:43:51,623 --> 04:43:52,623 say Edit Text name. If that's the case, let's\n 3952 04:43:52,623 --> 04:43:53,623 type something. Before I run my application,\n 3953 04:43:53,623 --> 04:43:54,623 not going to have a conflict between different\n 3954 04:43:54,623 --> 04:43:55,623 Hello, the text is going to be changed to\n 3955 04:43:55,623 --> 04:43:56,623 And if we click on the edit text itself, we\n 3956 04:43:56,623 --> 04:43:57,623 on the text, we can see the toast message\n 3957 04:43:57,623 --> 04:43:58,623 I think that's enough for this video. In the\n 3958 04:43:58,623 --> 04:43:59,623 other UI elements like checkboxes, radio buttons,\n 3959 04:43:59,623 --> 04:44:00,623 before I finish off this video, I'm going\n 3960 04:44:00,623 --> 04:44:01,623 at my website@miko.org slash code. So feel\n 3961 04:44:01,623 --> 04:44:02,623 you in the next video. The first UI element\n 3962 04:44:02,623 --> 04:44:03,623 is checkbox. Let's quickly see that in our\n 3963 04:44:03,623 --> 04:44:04,623 to delete this TextView. And also I'm going\n 3964 04:44:04,623 --> 04:44:05,623 layout. Then in here, we can create our checkbox\n 3965 04:44:05,623 --> 04:44:06,623 and height, let's say wrapped content. You\n 3966 04:44:06,623 --> 04:44:07,623 added in here. If you want we can add a text\n 3967 04:44:07,623 --> 04:44:08,623 I'm going to enter the name of a movie. So\n 3968 04:44:08,623 --> 04:44:09,623 as well as let's say ID. Let's name it checkbox\n 3969 04:44:09,623 --> 04:44:10,623 we can check or uncheck. For example, in here\n 3970 04:44:10,623 --> 04:44:11,623 pass through or false for this for example,\n 3971 04:44:11,623 --> 04:44:12,623 be checked. Let's quickly add two more checkboxes.\n 3972 04:44:12,623 --> 04:44:13,623 one two more times. But this time, first of\n 3973 04:44:13,623 --> 04:44:14,623 say the matrix. And also let's change the\n 3974 04:44:14,623 --> 04:44:15,623 attribute I'm going to move this new checkbox\n 3975 04:44:15,623 --> 04:44:16,623 that we have an attribute called to write\n 3976 04:44:16,623 --> 04:44:17,623 our first checkbox, let's say checkbox, Harry.\n 3977 04:44:17,623 --> 04:44:18,623 left and let's pass 15 If you For example,\n 3978 04:44:18,623 --> 04:44:19,623 let's change the text to let's say Joker.\n 3979 04:44:19,623 --> 04:44:20,623 Joker. And also let's move it to the right\nof checkbox matrix. 3980 04:44:20,623 --> 04:44:21,623 So this way, as you can see, we can have multiple\n 3981 04:44:21,623 --> 04:44:22,623 by default by setting an attribute of checked,\n 3982 04:44:22,623 --> 04:44:23,623 say, false. If we want to center this checkbox\n 3983 04:44:23,623 --> 04:44:24,623 first one. For example, we can say, margin\n 3984 04:44:24,623 --> 04:44:25,623 But as you can see, this is not accurate.\n 3985 04:44:25,623 --> 04:44:26,623 another relative layout and move all of these\n 3986 04:44:26,623 --> 04:44:27,623 Let's quickly see how we can do that. So inside\n 3987 04:44:27,623 --> 04:44:28,623 another relative layout. Let's say relative\n 3988 04:44:28,623 --> 04:44:29,623 wrap content. Let's also give it an ID. Let's\n 3989 04:44:29,623 --> 04:44:30,623 relative layouts. Now, if I want, I can center\n 3990 04:44:30,623 --> 04:44:31,623 let's pass through. Beside that let's add\n 3991 04:44:31,623 --> 04:44:32,623 In other UI elements normally in here, we\n 3992 04:44:32,623 --> 04:44:33,623 by adding a slashing here. But in this case,\n 3993 04:44:33,623 --> 04:44:34,623 to finish creating my first tag my opening\n 3994 04:44:34,623 --> 04:44:35,623 And as you can see, this closing tag has been\n 3995 04:44:35,623 --> 04:44:36,623 checkboxes inside these two tags, the opening\n 3996 04:44:36,623 --> 04:44:37,623 them to inside those two tags. If you noticed,\n 3997 04:44:37,623 --> 04:44:38,623 now centered horizontally, and also they have\n 3998 04:44:38,623 --> 04:44:39,623 parents layout which is this relative layout\n 3999 04:44:39,623 --> 04:44:40,623 you can have relative layout nested inside\n 4000 04:44:40,623 --> 04:44:41,623 what can we do with these checkboxes inside\n 4001 04:44:41,623 --> 04:44:42,623 my main activity dot java file. If you're\n 4002 04:44:42,623 --> 04:44:43,623 to see the search menu. First of all in here,\n 4003 04:44:43,623 --> 04:44:44,623 going to define them as fields, let's say\n 4004 04:44:44,623 --> 04:44:45,623 say checkbox, Harry. In here I have two options.\n 4005 04:44:45,623 --> 04:44:46,623 after line. For example, I can say private\n 4006 04:44:46,623 --> 04:44:47,623 it checkbox matrix. Or alternatively, because\n 4007 04:44:47,623 --> 04:44:48,623 can add a comma in here and I can define my\n 4008 04:44:48,623 --> 04:44:49,623 matrix. Let's also define the checkbox Joker.\n 4009 04:44:49,623 --> 04:44:50,623 let's instantiate them. Let's say checkbox\n 4010 04:44:50,623 --> 04:44:51,623 checkbox sorry. Similarly for the next two.\n 4011 04:44:51,623 --> 04:44:52,623 for each one of these checkboxes For example,\n 4012 04:44:52,623 --> 04:44:53,623 change listener, this is the listener that\n 4013 04:44:53,623 --> 04:44:54,623 Once again, you can see that this is an interface.\n 4014 04:44:54,623 --> 04:44:55,623 change listener. Inside this interface, we\n 4015 04:44:55,623 --> 04:44:56,623 we receive two elements. The compound button\n 4016 04:44:56,623 --> 04:44:57,623 and also this is checked Boolean. So in here,\n 4017 04:44:57,623 --> 04:44:58,623 is checked. Let's show a toast message. Let's\n 4018 04:44:58,623 --> 04:44:59,623 the else case, let's show another source message.\n 4019 04:44:59,623 --> 04:45:00,623 Harry Potter. Before I write the logic for\n 4020 04:45:00,623 --> 04:45:01,623 and let's see what would be the result. 4021 04:45:01,623 --> 04:45:02,623 Right now Harry Potter is checked but we are\n 4022 04:45:02,623 --> 04:45:03,623 the onclicklistener in here is going to react\n 4023 04:45:03,623 --> 04:45:04,623 if I uncheck this checkbox, we can see that\n 4024 04:45:04,623 --> 04:45:05,623 check it. You have watched Harry Potter. But\n 4025 04:45:05,623 --> 04:45:06,623 we run the application without any clicking\n 4026 04:45:06,623 --> 04:45:07,623 here before setting this onclicklistener.\n 4027 04:45:07,623 --> 04:45:08,623 or not. For example, for that I can create\n 4028 04:45:08,623 --> 04:45:09,623 checked. As you can see, this method is going\n 4029 04:45:09,623 --> 04:45:10,623 it's going to check that if our checkbox is\n 4030 04:45:10,623 --> 04:45:11,623 to show the toast message. Let's copy it from\n 4031 04:45:11,623 --> 04:45:12,623 another toast message. Once again, we can\n 4032 04:45:12,623 --> 04:45:13,623 As you can see, when I ran the application\n 4033 04:45:13,623 --> 04:45:14,623 So from time to time, this is check method\n 4034 04:45:14,623 --> 04:45:15,623 an onclicklistener for the next two checkboxes\n 4035 04:45:15,623 --> 04:45:16,623 like in the previous video, instead of passing\n 4036 04:45:16,623 --> 04:45:17,623 listener, you can implement this listener\n 4037 04:45:17,623 --> 04:45:18,623 in here, and after that you need to override\n 4038 04:45:18,623 --> 04:45:19,623 you can pass this instead of this new listener\n 4039 04:45:19,623 --> 04:45:20,623 method. But once again, I'm not going to go\n 4040 04:45:20,623 --> 04:45:21,623 our activity main dot XML file. And let's\n 4041 04:45:21,623 --> 04:45:22,623 that, I'm going to minimize this relative\n 4042 04:45:22,623 --> 04:45:23,623 to talk about is a radio button. That's a\n 4043 04:45:23,623 --> 04:45:24,623 width and height, let's say wrap content,\n 4044 04:45:24,623 --> 04:45:25,623 Let's move on to below our relative layout.\n 4045 04:45:25,623 --> 04:45:26,623 was named movies relative layout. Let's also\n 4046 04:45:26,623 --> 04:45:27,623 25 dP and also margin top of maybe 20 db,\n 4047 04:45:27,623 --> 04:45:28,623 a text. For the text, I'm just going to say\n 4048 04:45:28,623 --> 04:45:29,623 status of the user. So that's what this text\n 4049 04:45:29,623 --> 04:45:30,623 say radio button married. Like checkboxes.\n 4050 04:45:30,623 --> 04:45:31,623 you can say checked and you can pass through.\n 4051 04:45:31,623 --> 04:45:32,623 you can say something like this, you can copy\n 4052 04:45:32,623 --> 04:45:33,623 going to be some problem with our code. Before\n 4053 04:45:33,623 --> 04:45:34,623 radio button. For example in here, let's say\n 4054 04:45:34,623 --> 04:45:35,623 to RV singer. Let's also move this one to\n 4055 04:45:35,623 --> 04:45:36,623 say to write off radio button marriage. So\n 4056 04:45:36,623 --> 04:45:37,623 is that among multiple radio buttons, you\n 4057 04:45:37,623 --> 04:45:38,623 between radio button and checkbox. When you\n 4058 04:45:38,623 --> 04:45:39,623 both when you have radio buttons, you can\n 4059 04:45:39,623 --> 04:45:40,623 you can see, our program is not functioning\n 4060 04:45:40,623 --> 04:45:41,623 to group these radio buttons. And we can do\n 4061 04:45:41,623 --> 04:45:42,623 radio group. Before that, I'm going to delete\n 4062 04:45:42,623 --> 04:45:43,623 This one. Once again, for the width and height\n 4063 04:45:43,623 --> 04:45:44,623 it below our movies relative layout. 4064 04:45:44,623 --> 04:45:45,623 Layout below ID movies rely on a margin top\n 4065 04:45:45,623 --> 04:45:46,623 center horizontal to true. Once again, because\n 4066 04:45:46,623 --> 04:45:47,623 this radio group, I'm not going to finish\n 4067 04:45:47,623 --> 04:45:48,623 to finish creating this opening tag by adding\n 4068 04:45:48,623 --> 04:45:49,623 you can see that now we have an opening tag\n 4069 04:45:49,623 --> 04:45:50,623 group. I can have my radio buttons, let's\n 4070 04:45:50,623 --> 04:45:51,623 Let's give it an ID let's say radio button\n 4071 04:45:51,623 --> 04:45:52,623 It's default value to checked, let's say checked\n 4072 04:45:52,623 --> 04:45:53,623 Let's copy and paste this one. So as you can\n 4073 04:45:53,623 --> 04:45:54,623 our first radio button, but it's moved automatically.\n 4074 04:45:54,623 --> 04:45:55,623 you can see that even though both of these\n 4075 04:45:55,623 --> 04:45:56,623 them is showing the checked value, so when\n 4076 04:45:56,623 --> 04:45:57,623 can have a checked value. For that, I'm going\n 4077 04:45:57,623 --> 04:45:58,623 second radio button. And also I'm going to\n 4078 04:45:58,623 --> 04:45:59,623 another one. For the ID, let's say radio button\n 4079 04:45:59,623 --> 04:46:00,623 relationship. Let's also delete this check\n 4080 04:46:00,623 --> 04:46:01,623 vertical. If you want, you can have horizontal\n 4081 04:46:01,623 --> 04:46:02,623 radio group. You can have an attribute called\n 4082 04:46:02,623 --> 04:46:03,623 or vertical. If I pass horizontal, you can\n 4083 04:46:03,623 --> 04:46:04,623 ordered, I think it's better to have some\n 4084 04:46:04,623 --> 04:46:05,623 quickly add some margins. Let's say margin\n 4085 04:46:05,623 --> 04:46:06,623 one down in here. Okay, now let's see how\n 4086 04:46:06,623 --> 04:46:07,623 group inside our Java file. For that I do\n 4087 04:46:07,623 --> 04:46:08,623 I just need to instantiate my radio group,\n 4088 04:46:08,623 --> 04:46:09,623 group marital status. But I believe I need\n 4089 04:46:09,623 --> 04:46:10,623 I didn't do that. Yes, in here I can see ID\n 4090 04:46:10,623 --> 04:46:11,623 I create method that's also minimize this\n 4091 04:46:11,623 --> 04:46:12,623 And after the checkboxes, let's instantiate\n 4092 04:46:12,623 --> 04:46:13,623 status, fine view by ID r.id dot, radio group\n 4093 04:46:13,623 --> 04:46:14,623 for this radio group by saying radio group\n 4094 04:46:14,623 --> 04:46:15,623 method is going to be called whenever we change\n 4095 04:46:15,623 --> 04:46:16,623 parentheses, you can guess I can pass new\n 4096 04:46:16,623 --> 04:46:17,623 unchecked change listener, which is an interface\n 4097 04:46:17,623 --> 04:46:18,623 One of the inputs of this method is this check\n 4098 04:46:18,623 --> 04:46:19,623 can create the switch statement on this check\n 4099 04:46:19,623 --> 04:46:20,623 in case it's our.id dot, let's say radio button\n 4100 04:46:20,623 --> 04:46:21,623 ID of our radio button, whichever is selected.\n 4101 04:46:21,623 --> 04:46:22,623 button married, I'm going to show a toast\n 4102 04:46:22,623 --> 04:46:23,623 it's our that Id dot, let's say radio button\n 4103 04:46:23,623 --> 04:46:24,623 Let's also add another case for RV in well.\n 4104 04:46:24,623 --> 04:46:25,623 And let's add a break. Let's run our application.\n 4105 04:46:25,623 --> 04:46:26,623 Right now this married is selected. If we\n 4106 04:46:26,623 --> 04:46:27,623 one has been unchecked. And also we have saw\n 4107 04:46:27,623 --> 04:46:28,623 You can see the toast message which is perfect.\n 4108 04:46:28,623 --> 04:46:29,623 different radio buttons inside this radio\n 4109 04:46:29,623 --> 04:46:30,623 doing something for example, in this case,\n 4110 04:46:30,623 --> 04:46:31,623 want to do something without clicking on these\n 4111 04:46:31,623 --> 04:46:32,623 our code. So before this set on check change\n 4112 04:46:32,623 --> 04:46:33,623 dot get checked radio button ID. As you can\n 4113 04:46:33,623 --> 04:46:34,623 radio button. And I can save that inside an\n 4114 04:46:34,623 --> 04:46:35,623 button. After that, I can create a similar\n 4115 04:46:35,623 --> 04:46:36,623 So let's say switch on the checked button.\n 4116 04:46:36,623 --> 04:46:37,623 and paste the cases from here. Let's run the\n 4117 04:46:37,623 --> 04:46:38,623 result. As you can see, we are not clicking\n 4118 04:46:38,623 --> 04:46:39,623 saw the Maritimes that seems to be perfect.\n 4119 04:46:39,623 --> 04:46:40,623 the checked radio button before clicking on\n 4120 04:46:40,623 --> 04:46:41,623 in this video. And that's called a progress\n 4121 04:46:41,623 --> 04:46:42,623 that, I'm going to minimize this radio group.\n 4122 04:46:42,623 --> 04:46:43,623 bar, draft content and wrap content. Let's\n 4123 04:46:43,623 --> 04:46:44,623 also center it, let's say center and parent.\n 4124 04:46:44,623 --> 04:46:45,623 And let's see what our application is going\n 4125 04:46:45,623 --> 04:46:46,623 can see, an infinite progress bar is constantly\n 4126 04:46:46,623 --> 04:46:47,623 when we are downloading something from the\n 4127 04:46:47,623 --> 04:46:48,623 visible or on visible, we have an option.\n 4128 04:46:48,623 --> 04:46:49,623 to be not visible, we can say visibility.\n 4129 04:46:49,623 --> 04:46:50,623 attribute for almost all of the other UI elements.\n 4130 04:46:50,623 --> 04:46:51,623 by default, it's visible. Let's change it\n 4131 04:46:51,623 --> 04:46:52,623 need to change this visibility to visible\n 4132 04:46:52,623 --> 04:46:53,623 to change it to gone. Let's see how can we\n 4133 04:46:53,623 --> 04:46:54,623 let's minimize all of the extra methods and\n 4134 04:46:54,623 --> 04:46:55,623 bar. Above in here, I'm going to say private\n 4135 04:46:55,623 --> 04:46:56,623 And then in here inside the onCreate method,\n 4136 04:46:56,623 --> 04:46:57,623 by ID r.id dot progress bar. I do not have\n 4137 04:46:57,623 --> 04:46:58,623 visibility of this progress bar. Instead,\n 4138 04:46:58,623 --> 04:46:59,623 the user clicks on the radio button singer\n 4139 04:46:59,623 --> 04:47:00,623 listener inside the switch case, in case if\n 4140 04:47:00,623 --> 04:47:01,623 toast message or after the toast message,\n 4141 04:47:01,623 --> 04:47:02,623 And I can say visible means that whenever\n 4142 04:47:02,623 --> 04:47:03,623 I'm going to change the visibility of my progress\n 4143 04:47:03,623 --> 04:47:04,623 And after the toast message. let's paste that.\n 4144 04:47:04,623 --> 04:47:05,623 view.com. Let's run our application. 4145 04:47:05,623 --> 04:47:06,623 Right now we cannot see any progress bar because\n 4146 04:47:06,623 --> 04:47:07,623 attribute and we have set the gun value in\n 4147 04:47:07,623 --> 04:47:08,623 that we are seeing the progress bar. In case\n 4148 04:47:08,623 --> 04:47:09,623 can guess the visibility will be changed to\n 4149 04:47:09,623 --> 04:47:10,623 bar. Let's quickly see that as well. So in\n 4150 04:47:10,623 --> 04:47:11,623 a style for my progress. But before that,\n 4151 04:47:11,623 --> 04:47:12,623 to visible in order to see the progress bar\n 4152 04:47:12,623 --> 04:47:13,623 style. If I type horizontal, we can see this\n 4153 04:47:13,623 --> 04:47:14,623 bar dot horizontal. Let's change the width\n 4154 04:47:14,623 --> 04:47:15,623 And also in here I have another option I can\n 4155 04:47:15,623 --> 04:47:16,623 example, I can say 30 you can see that the\n 4156 04:47:16,623 --> 04:47:17,623 to 30. This type of progress bar is extremely\n 4157 04:47:17,623 --> 04:47:18,623 of something for example, downloading a file.\n 4158 04:47:18,623 --> 04:47:19,623 of the file has been downloaded. You can also\n 4159 04:47:19,623 --> 04:47:20,623 you can see Max and can pass 100. Let's also\n 4160 04:47:20,623 --> 04:47:21,623 of 20 dP margin right after ntdp. Okay, now\n 4161 04:47:21,623 --> 04:47:22,623 see what we can do with this progress bar.\n 4162 04:47:22,623 --> 04:47:23,623 two lines of code, because I'm not going to\n 4163 04:47:23,623 --> 04:47:24,623 Let's also minimize this switch statement\n 4164 04:47:24,623 --> 04:47:25,623 after instantiating, our progress bar, I'm\n 4165 04:47:25,623 --> 04:47:26,623 from the Java session, this is the simplest\n 4166 04:47:26,623 --> 04:47:27,623 threat threat is equal to new threat, we needed\n 4167 04:47:27,623 --> 04:47:28,623 Inside this run method, I'm going to create\n 4168 04:47:28,623 --> 04:47:29,623 zero, i less than 10, i plus plus, for every\n 4169 04:47:29,623 --> 04:47:30,623 progress of this progress bar by 10. So let's\n 4170 04:47:30,623 --> 04:47:31,623 by as you can guess we need to pass an integer\n 4171 04:47:31,623 --> 04:47:32,623 that. Let's freeze this thread for half a\n 4172 04:47:32,623 --> 04:47:33,623 we have used this way we said thread dot sleep.\n 4173 04:47:33,623 --> 04:47:34,623 we create interrupted exceptions. For example,\n 4174 04:47:34,623 --> 04:47:35,623 And the error says that unhandled exception.\n 4175 04:47:35,623 --> 04:47:36,623 going to use that in here. I can say system\n 4176 04:47:36,623 --> 04:47:37,623 to create a try catch block. This wasn't available\n 4177 04:47:37,623 --> 04:47:38,623 Android dot voice, you can check that by take\n 4178 04:47:38,623 --> 04:47:39,623 Android dot o s that system collect is the\n 4179 04:47:39,623 --> 04:47:40,623 our thread, we just need to start it we can\n 4180 04:47:40,623 --> 04:47:41,623 we can say thread dot start. So in here, we\n 4181 04:47:41,623 --> 04:47:42,623 that we are creating a for loop. And for each\n 4182 04:47:42,623 --> 04:47:43,623 of our progress bar by 10. Also, after each\n 4183 04:47:43,623 --> 04:47:44,623 thread for half a second. Let's quickly switch\n 4184 04:47:44,623 --> 04:47:45,623 this progress attribute it was just for demonstration.\n 4185 04:47:45,623 --> 04:47:46,623 the progress will change to zero. Let's run\n 4186 04:47:46,623 --> 04:47:47,623 the progress of our progress bar. As you can\n 4187 04:47:47,623 --> 04:47:48,623 bar for every half a second. If you want,\n 4188 04:47:48,623 --> 04:47:49,623 bar at any moment that you want. For example,\n 4189 04:47:49,623 --> 04:47:50,623 As you can see this get progress is returning\n 4190 04:47:50,623 --> 04:47:51,623 your progress bar. Sometimes you may need\n 4191 04:47:51,623 --> 04:47:52,623 Okay, I think that's enough for this video.\n 4192 04:47:52,623 --> 04:47:53,623 to upload the source code at my website@maker.org\n 4193 04:47:53,623 --> 04:47:54,623 need and also in the next video. Finally,\n 4194 04:47:54,623 --> 04:47:55,623 between a relative layout, a constraint layout\n 4195 04:47:55,623 --> 04:47:56,623 to help you a lot with understanding the layout\n 4196 04:47:56,623 --> 04:47:57,623 In this video, we will talk about different\n 4197 04:47:57,623 --> 04:47:58,623 talk about relative layout, we will talk about\n 4198 04:47:58,623 --> 04:47:59,623 Let's start by talking about the relative\n 4199 04:47:59,623 --> 04:48:00,623 text view in my layout file. Let's also minimize\n 4200 04:48:00,623 --> 04:48:01,623 constraint layout to relative layout. I'm\n 4201 04:48:01,623 --> 04:48:02,623 we can see what we are doing. First of all,\n 4202 04:48:02,623 --> 04:48:03,623 from the beginning. So inside the relative\n 4203 04:48:03,623 --> 04:48:04,623 related to each other, it means that the place\n 4204 04:48:04,623 --> 04:48:05,623 layout, or maybe its parent, let's quickly\n 4205 04:48:05,623 --> 04:48:06,623 in action. Like before, I'm going to say wrap\n 4206 04:48:06,623 --> 04:48:07,623 specify a text. Let's just say hello world.\n 4207 04:48:07,623 --> 04:48:08,623 at the left corner of my screen if I want\n 4208 04:48:08,623 --> 04:48:09,623 in the previous videos that I Can center this\n 4209 04:48:09,623 --> 04:48:10,623 I can say center horizontal. Let's pass through,\n 4210 04:48:10,623 --> 04:48:11,623 this is the relativity that I was talking\n 4211 04:48:11,623 --> 04:48:12,623 attribute to true. We are defining relativity\n 4212 04:48:12,623 --> 04:48:13,623 also center it vertically. Or instead of these\n 4213 04:48:13,623 --> 04:48:14,623 parent. Let's also give an ID to this TextView.\n 4214 04:48:14,623 --> 04:48:15,623 UI element, I can place that related to this\n 4215 04:48:15,623 --> 04:48:16,623 here. Let's say wrap content and wrap content\n 4216 04:48:16,623 --> 04:48:17,623 Like before, let's say Say hello. Also, let's\n 4217 04:48:17,623 --> 04:48:18,623 to below this TextView, I can simply say layout\n 4218 04:48:18,623 --> 04:48:19,623 txt Hello, I can center this button as well.\n 4219 04:48:19,623 --> 04:48:20,623 And let's pass through, we can also have a\n 4220 04:48:20,623 --> 04:48:21,623 layout margin top and we can pass some number\n 4221 04:48:21,623 --> 04:48:22,623 you can also have another relative layout.\n 4222 04:48:22,623 --> 04:48:23,623 I'm going to define a relative layout and\n 4223 04:48:23,623 --> 04:48:24,623 put three text views. After that, I'm going\n 4224 04:48:24,623 --> 04:48:25,623 below that relative layout. So I can see relative\n 4225 04:48:25,623 --> 04:48:26,623 wrap content, you can say match parent. Like\n 4226 04:48:26,623 --> 04:48:27,623 our relative layout. For example, I can say\n 4227 04:48:27,623 --> 04:48:28,623 when we wanted to create our UI elements after\n 4228 04:48:28,623 --> 04:48:29,623 this backslash in order to finish creating\n 4229 04:48:29,623 --> 04:48:30,623 we are going to put some other elements inside\n 4230 04:48:30,623 --> 04:48:31,623 opening tag and instead of using the backslash,\n 4231 04:48:31,623 --> 04:48:32,623 By doing that, we also create this ending\n 4232 04:48:32,623 --> 04:48:33,623 now we can put our UI elements. For example,\n 4233 04:48:33,623 --> 04:48:34,623 Wrap content wrap content, I'm going to fast\n 4234 04:48:34,623 --> 04:48:35,623 Like before, we can place our two text views\n 4235 04:48:35,623 --> 04:48:36,623 example, we can move them to right of each\n 4236 04:48:36,623 --> 04:48:37,623 say to right off, let's say txt name, let's\n 4237 04:48:37,623 --> 04:48:38,623 for this third TextView, let's say to write\n 4238 04:48:38,623 --> 04:48:39,623 maybe 10 dP once again, once again, this whole\n 4239 04:48:39,623 --> 04:48:40,623 of our screen. If we want, we can use the\n 4240 04:48:40,623 --> 04:48:41,623 for this whole relative layout as well. So\n 4241 04:48:41,623 --> 04:48:42,623 I can say center for example. And let's fast\n 4242 04:48:42,623 --> 04:48:43,623 say margin top. And that's past 100 dP. You\n 4243 04:48:43,623 --> 04:48:44,623 a relative layout level, all of the UI elements\n 4244 04:48:44,623 --> 04:48:45,623 attributes. For example, in here we have centered\n 4245 04:48:45,623 --> 04:48:46,623 Now that we have this relative layout, we\n 4246 04:48:46,623 --> 04:48:47,623 better. And after that, we can move this Hello\n 4247 04:48:47,623 --> 04:48:48,623 that, I need to delete the center parent attribute.\n 4248 04:48:48,623 --> 04:48:49,623 corner of our screen and because we have set\n 4249 04:48:49,623 --> 04:48:50,623 as well. So in here I can say layout below\n 4250 04:48:50,623 --> 04:48:51,623 it was first relative layer. Let's also center\n 4251 04:48:51,623 --> 04:48:52,623 Center horizontal through margin top, let's\n 4252 04:48:52,623 --> 04:48:53,623 inside a relatively at or for that matter\n 4253 04:48:53,623 --> 04:48:54,623 other relative layouts as well. Some of these\n 4254 04:48:54,623 --> 04:48:55,623 are specific to relative layout. And if you're\n 4255 04:48:55,623 --> 04:48:56,623 a linear layout, and also constraint layout,\n 4256 04:48:56,623 --> 04:48:57,623 course, we will see that each of these attributes\n 4257 04:48:57,623 --> 04:48:58,623 move to the next kind of layouts, let's also\n 4258 04:48:58,623 --> 04:48:59,623 in here, you can see this component three,\n 4259 04:48:59,623 --> 04:49:00,623 This in here is showing us the hierarchy of\n 4260 04:49:00,623 --> 04:49:01,623 in here, we have this parent relative layout.\n 4261 04:49:01,623 --> 04:49:02,623 and also txt, hello, and btn. Hello. Inside\n 4262 04:49:02,623 --> 04:49:03,623 views. Sometimes when you have a messy UI,\n 4263 04:49:03,623 --> 04:49:04,623 keep track of different UI elements. Okay,\n 4264 04:49:04,623 --> 04:49:05,623 start talking about linear layout. Before\n 4265 04:49:05,623 --> 04:49:06,623 let's change the strategy of layout to a linear\n 4266 04:49:06,623 --> 04:49:07,623 UI elements will be placed line after line,\n 4267 04:49:07,623 --> 04:49:08,623 a TextView. Once again, wrap content and wrap\n 4268 04:49:08,623 --> 04:49:09,623 world once again. Let's also give it an ID.\n 4269 04:49:09,623 --> 04:49:10,623 is different inside a linear layout is that\n 4270 04:49:10,623 --> 04:49:11,623 horizontally or center vertically attributes\n 4271 04:49:11,623 --> 04:49:12,623 here, I cannot say centering parent, you can\n 4272 04:49:12,623 --> 04:49:13,623 center your UI elements, you can have for\n 4273 04:49:13,623 --> 04:49:14,623 layout. Let's move on from this part. And\n 4274 04:49:14,623 --> 04:49:15,623 wrap content wrap content for the text, let's\nsay Say hello. 4275 04:49:15,623 --> 04:49:16,623 And let's give it an ID, let's say btn. Hello,\n 4276 04:49:16,623 --> 04:49:17,623 any attribute to move this button to the right\n 4277 04:49:17,623 --> 04:49:18,623 the right of our TextView. And that's because\n 4278 04:49:18,623 --> 04:49:19,623 layout, all of our UI elements will be placed\n 4279 04:49:19,623 --> 04:49:20,623 the orientation of this linear layout so that\n 4280 04:49:20,623 --> 04:49:21,623 vertically. Let's quickly do that. So in the\n 4281 04:49:21,623 --> 04:49:22,623 to pass an attribute in here, let's say orientation.\n 4282 04:49:22,623 --> 04:49:23,623 have been placed vertically. There is also\n 4283 04:49:23,623 --> 04:49:24,623 in linear layout. Let's quickly delete this\n 4284 04:49:24,623 --> 04:49:25,623 For the text, let's say name. And for the\n 4285 04:49:25,623 --> 04:49:26,623 the margins. For example, you can say margin\n 4286 04:49:26,623 --> 04:49:27,623 But there is also another attribute in here\n 4287 04:49:27,623 --> 04:49:28,623 to give some background color for these two\n 4288 04:49:28,623 --> 04:49:29,623 better. So I can say background, and I can\n 4289 04:49:29,623 --> 04:49:30,623 that we have in our color resource. Let's\n 4290 04:49:30,623 --> 04:49:31,623 Let's say background, and let's fast color\n 4291 04:49:31,623 --> 04:49:32,623 I'm going to talk about is wait. Let's quickly\n 4292 04:49:32,623 --> 04:49:33,623 And we can pass any number that we want. For\n 4293 04:49:33,623 --> 04:49:34,623 to this second TextView. And we will talk\n 4294 04:49:34,623 --> 04:49:35,623 example, you can probably guess the usage\n 4295 04:49:35,623 --> 04:49:36,623 give our attribute so weight according to\n 4296 04:49:36,623 --> 04:49:37,623 in this case, the entire width of our layout\n 4297 04:49:37,623 --> 04:49:38,623 the first TextView 20% of the weight of the\n 4298 04:49:38,623 --> 04:49:39,623 you put in here. For example, in here, if\n 4299 04:49:39,623 --> 04:49:40,623 eight, it will work the same. Also, you can\n 4300 04:49:40,623 --> 04:49:41,623 have this margin top if we remove that, you\n 4301 04:49:41,623 --> 04:49:42,623 accordingly. So this rate was another attribute\n 4302 04:49:42,623 --> 04:49:43,623 this orientation to horizontal, you can see\n 4303 04:49:43,623 --> 04:49:44,623 to this linear layout, I just wanted to show\n 4304 04:49:44,623 --> 04:49:45,623 some specific attributes, for example, this\n 4305 04:49:45,623 --> 04:49:46,623 we are not going to use linear layout that\n 4306 04:49:46,623 --> 04:49:47,623 use it if you want. Before I remove all of\n 4307 04:49:47,623 --> 04:49:48,623 layout, you can also have other layouts, for\n 4308 04:49:48,623 --> 04:49:49,623 layout. Okay, let's remove one of these. And\n 4309 04:49:49,623 --> 04:49:50,623 that, I'm going to remove this orientation\n 4310 04:49:50,623 --> 04:49:51,623 Okay, let's say constraint layout. We have\n 4311 04:49:51,623 --> 04:49:52,623 visa dot constraint layout, this is the one\n 4312 04:49:52,623 --> 04:49:53,623 layout, I'm going to switch to design view\n 4313 04:49:53,623 --> 04:49:54,623 the design view. First of all, I'm going to\n 4314 04:49:54,623 --> 04:49:55,623 difference. If there is any, you can click\n 4315 04:49:55,623 --> 04:49:56,623 this design plus blueprint, we will talk about\n 4316 04:49:56,623 --> 04:49:57,623 this blueprint in a minute. Okay, for working\n 4317 04:49:57,623 --> 04:49:58,623 UI elements like before you can drag, for\n 4318 04:49:58,623 --> 04:49:59,623 that, you can see that we have four circles\n 4319 04:49:59,623 --> 04:50:00,623 zoom in a little bit, you can see that the\n 4320 04:50:00,623 --> 04:50:01,623 UI element. Let's zoom out a bit, I just wanted\n 4321 04:50:01,623 --> 04:50:02,623 that I'm using in here is Ctrl. Plus Plus\n 4322 04:50:02,623 --> 04:50:03,623 in order to zoom out. Also at any time, you\n 4323 04:50:03,623 --> 04:50:04,623 fit screen. It's also worth mentioning that\n 4324 04:50:04,623 --> 04:50:05,623 and keys for the calculator, the plus minus\n 4325 04:50:05,623 --> 04:50:06,623 going to be helpful in here. So the shortcuts\n 4326 04:50:06,623 --> 04:50:07,623 using the upper numbers. And also the upper\n 4327 04:50:07,623 --> 04:50:08,623 constraint layout is to constrain your UI\n 4328 04:50:08,623 --> 04:50:09,623 a red area in here. Similarly, we have the\n 4329 04:50:09,623 --> 04:50:10,623 that we need to constraint your UI element.\n 4330 04:50:10,623 --> 04:50:11,623 can drag one of these circles to for example,\n 4331 04:50:11,623 --> 04:50:12,623 added one constraint, if we switch back to\n 4332 04:50:12,623 --> 04:50:13,623 constraint in here. I'm talking about these\n 4333 04:50:13,623 --> 04:50:14,623 to the design view, we can add another constraint.\n 4334 04:50:14,623 --> 04:50:15,623 UI element, we can add the constraint to the\n 4335 04:50:15,623 --> 04:50:16,623 layout is not happy. It says that not vertically\n 4336 04:50:16,623 --> 04:50:17,623 add another constraint in here. And now the\n 4337 04:50:17,623 --> 04:50:18,623 some warning. If you want to center your UI\n 4338 04:50:18,623 --> 04:50:19,623 can add another constraint for example, from\n 4339 04:50:19,623 --> 04:50:20,623 of the screen. If you want to remove one of\n 4340 04:50:20,623 --> 04:50:21,623 circle and you can press the delete key, you\n 4341 04:50:21,623 --> 04:50:22,623 Let's press Ctrl Z in order to redo that.\n 4342 04:50:22,623 --> 04:50:23,623 here, you can see that you have a slider for\n 4343 04:50:23,623 --> 04:50:24,623 now the number says 50. But if you want you\n 4344 04:50:24,623 --> 04:50:25,623 it a little bit, you can see that the TextView\n 4345 04:50:25,623 --> 04:50:26,623 to this slider. Similar to that we have this\n 4346 04:50:26,623 --> 04:50:27,623 can move our UI element. So constraining your\n 4347 04:50:27,623 --> 04:50:28,623 way you can also add constraints to other\n 4348 04:50:28,623 --> 04:50:29,623 in here, let's quickly add that and let's\n 4349 04:50:29,623 --> 04:50:30,623 of them. Let's move it so that we can see\n 4350 04:50:30,623 --> 04:50:31,623 we can constrain this button to for example,\n 4351 04:50:31,623 --> 04:50:32,623 it moves accordingly. You can also see that\n 4352 04:50:32,623 --> 04:50:33,623 see all of the available targets for example,\n 4353 04:50:33,623 --> 04:50:34,623 sometimes it might not work, and you may want\n 4354 04:50:34,623 --> 04:50:35,623 have constraints with our button to the bottom\n 4355 04:50:35,623 --> 04:50:36,623 this TextView. If we want to make it center,\n 4356 04:50:36,623 --> 04:50:37,623 of this TextView. And both of these UI elements\n 4357 04:50:37,623 --> 04:50:38,623 margin so that we can see everything better.\n 4358 04:50:38,623 --> 04:50:39,623 you can see that in the attributes pane, we\n 4359 04:50:39,623 --> 04:50:40,623 add 32. If you take a look at this componentry\n 4360 04:50:40,623 --> 04:50:41,623 about this button. But we have an error about\n 4361 04:50:41,623 --> 04:50:42,623 the necessary constraints about this button.\n 4362 04:50:42,623 --> 04:50:43,623 this TextView. For example, we need to constraint\n 4363 04:50:43,623 --> 04:50:44,623 Like before, we can add the constraints to\n 4364 04:50:44,623 --> 04:50:45,623 see that when I add the constraint, this button\n 4365 04:50:45,623 --> 04:50:46,623 this TextView is, we want our button to be\n 4366 04:50:46,623 --> 04:50:47,623 one. Let's also add a margin top for this\nTextView as well. 4367 04:50:47,623 --> 04:50:48,623 I think 32 is not enough. So let's say 100.\n 4368 04:50:48,623 --> 04:50:49,623 see other kinds of constraints. So constraining\n 4369 04:50:49,623 --> 04:50:50,623 this TextView to the top of this TextView.\n 4370 04:50:50,623 --> 04:50:51,623 of this TextView is one way of having two\n 4371 04:50:51,623 --> 04:50:52,623 There is also another way, I'm going to press\n 4372 04:50:52,623 --> 04:50:53,623 we can right click on one of our UI elements,\n 4373 04:50:53,623 --> 04:50:54,623 you can see this baseline, instead of adding\n 4374 04:50:54,623 --> 04:50:55,623 can select this baseline, and we can constraint\n 4375 04:50:55,623 --> 04:50:56,623 time, once again, they are at the same line\n 4376 04:50:56,623 --> 04:50:57,623 In order to navigate through all of your layout,\n 4377 04:50:57,623 --> 04:50:58,623 your mouse like if you work with Photoshop,\n 4378 04:50:58,623 --> 04:50:59,623 both of these text views are at the same line\n 4379 04:50:59,623 --> 04:51:00,623 the baseline. Once again, the baseline is\n 4380 04:51:00,623 --> 04:51:01,623 and you can select this show baseline. Let's\n 4381 04:51:01,623 --> 04:51:02,623 our UI element to know both edges of our screen.\n 4382 04:51:02,623 --> 04:51:03,623 another line for example, if we want to move\n 4383 04:51:03,623 --> 04:51:04,623 to some other space beside these two edges.\n 4384 04:51:04,623 --> 04:51:05,623 down in here inside these helpers. We have\n 4385 04:51:05,623 --> 04:51:06,623 add horizontal guideline, you can guess each\n 4386 04:51:06,623 --> 04:51:07,623 let's add a vertical guideline. Let's zoom\n 4387 04:51:07,623 --> 04:51:08,623 you can see that this line has been added\n 4388 04:51:08,623 --> 04:51:09,623 we can move it to the right of our screen.\n 4389 04:51:09,623 --> 04:51:10,623 have some margin from the left side of our\n 4390 04:51:10,623 --> 04:51:11,623 If I click on that, it will change the margin\n 4391 04:51:11,623 --> 04:51:12,623 this might be useful as well. Right now the\n 4392 04:51:12,623 --> 04:51:13,623 our screen, let's quickly delete the left\n 4393 04:51:13,623 --> 04:51:14,623 we can add this constraint to this guideline,\n 4394 04:51:14,623 --> 04:51:15,623 once again, it might not work. You can see\n 4395 04:51:15,623 --> 04:51:16,623 to this guideline instead of the edge of our\n 4396 04:51:16,623 --> 04:51:17,623 TextView to this guideline as well. But before\n 4397 04:51:17,623 --> 04:51:18,623 Let's quickly delete that, sorry, I deleted\n 4398 04:51:18,623 --> 04:51:19,623 to this guideline and also to the edge of\n 4399 04:51:19,623 --> 04:51:20,623 multiple guidelines, we will add another one\n 4400 04:51:20,623 --> 04:51:21,623 right click on the layouts. by going to this\n 4401 04:51:21,623 --> 04:51:22,623 We can see that this guideline has been added\n 4402 04:51:22,623 --> 04:51:23,623 guideline. We also have a vertical guideline.\n 4403 04:51:23,623 --> 04:51:24,623 guideline. We can Guess it will add a horizontal\n 4404 04:51:24,623 --> 04:51:25,623 in here, if we click on that it will change\n 4405 04:51:25,623 --> 04:51:26,623 constrain this TextView to our guideline.\n 4406 04:51:26,623 --> 04:51:27,623 UI elements in a constraint layout, adding\n 4407 04:51:27,623 --> 04:51:28,623 example, here, we don't have much space. For\n 4408 04:51:28,623 --> 04:51:29,623 we want to add constraints, for example, this\n 4409 04:51:29,623 --> 04:51:30,623 multiple UI elements by pressing down the\n 4410 04:51:30,623 --> 04:51:31,623 of them, you can right click, you can go to\n 4411 04:51:31,623 --> 04:51:32,623 our TextView to which is the ID of this TextView\n 4412 04:51:32,623 --> 04:51:33,623 two, let's say bottom of our guideline tree.\n 4413 04:51:33,623 --> 04:51:34,623 where there is not much space to work with,\n 4414 04:51:34,623 --> 04:51:35,623 this constraint, you can add the required\n 4415 04:51:35,623 --> 04:51:36,623 need to select the path of items that you\n 4416 04:51:36,623 --> 04:51:37,623 guideline. Or if you want to add the constraint\n 4417 04:51:37,623 --> 04:51:38,623 you can select this TextView and this button.\n 4418 04:51:38,623 --> 04:51:39,623 of this TextView to this guideline, we can\n 4419 04:51:39,623 --> 04:51:40,623 move it accordingly to right and left, you\n 4420 04:51:40,623 --> 04:51:41,623 the UI elements move as well. But depending\n 4421 04:51:41,623 --> 04:51:42,623 be a slow because as you can see, where we\n 4422 04:51:42,623 --> 04:51:43,623 If you want, you can disable this live rendering,\n 4423 04:51:43,623 --> 04:51:44,623 uncheck this live rendering. Let's zoom in\n 4424 04:51:44,623 --> 04:51:45,623 you can see that the UI elements themselves\n 4425 04:51:45,623 --> 04:51:46,623 every UI element. So in some cases, when you\n 4426 04:51:46,623 --> 04:51:47,623 for example, some large amount of memory RAM,\n 4427 04:51:47,623 --> 04:51:48,623 here, you can see the difference between this\n 4428 04:51:48,623 --> 04:51:49,623 see that when I moved this guideline, the\n 4429 04:51:49,623 --> 04:51:50,623 moving accordingly. And that's because the\n 4430 04:51:50,623 --> 04:51:51,623 at all. It's just some blueprint of all of\n 4431 04:51:51,623 --> 04:51:52,623 image view to our layout, we will see the\n 4432 04:51:52,623 --> 04:51:53,623 from this part. Sometimes when you're creating\n 4433 04:51:53,623 --> 04:51:54,623 sample data, or as we might call it in programming,\n 4434 04:51:54,623 --> 04:51:55,623 example, right now, the placeholder for this\n 4435 04:51:55,623 --> 04:51:56,623 can change that, we can right click on our\n 4436 04:51:56,623 --> 04:51:57,623 And we can select some text, we can see that\n 4437 04:51:57,623 --> 04:51:58,623 the text of our TextView to Shanghai, for\n 4438 04:51:58,623 --> 04:51:59,623 popular choice is this date in here, you can\n 4439 04:51:59,623 --> 04:52:00,623 and we can have some sample data about the\n 4440 04:52:00,623 --> 04:52:01,623 search on the internet for sample text, you\n 4441 04:52:01,623 --> 04:52:02,623 select that. And we can have some sample text.\n 4442 04:52:02,623 --> 04:52:03,623 on our layout, we also have the Lorem text.\n 4443 04:52:03,623 --> 04:52:04,623 So instead of Lorem random, we can select\n 4444 04:52:04,623 --> 04:52:05,623 text. Before we finish off this video, let's\n 4445 04:52:05,623 --> 04:52:06,623 as well. I know that we didn't talk about\n 4446 04:52:06,623 --> 04:52:07,623 talk about that in the next video, we can\n 4447 04:52:07,623 --> 04:52:08,623 thing we need to set some sample data for\n 4448 04:52:08,623 --> 04:52:09,623 from the avatars. Right now this is the avatar\n 4449 04:52:09,623 --> 04:52:10,623 If you want to you can change that by right\n 4450 04:52:10,623 --> 04:52:11,623 select another avatar or we can select one\n 4451 04:52:11,623 --> 04:52:12,623 select another avatar. For example this one\n 4452 04:52:12,623 --> 04:52:13,623 for example to the both edges of your TextView.\n 4453 04:52:13,623 --> 04:52:14,623 at the attributes painting here, you can see\n 4454 04:52:14,623 --> 04:52:15,623 width to content, we can change that, for\n 4455 04:52:15,623 --> 04:52:16,623 we do that, the width of our image view will\n 4456 04:52:16,623 --> 04:52:17,623 which is this TextView in this case. But there\n 4457 04:52:17,623 --> 04:52:18,623 this layout width to match constraint. When\n 4458 04:52:18,623 --> 04:52:19,623 inside this constraint widget, you can see\n 4459 04:52:19,623 --> 04:52:20,623 on that. And once I do that, you can see that\n 4460 04:52:20,623 --> 04:52:21,623 for when you want to show some images from\n 4461 04:52:21,623 --> 04:52:22,623 or the ratio of your image. Right now, the\n 4462 04:52:22,623 --> 04:52:23,623 change that, for example, you can say one\n 4463 04:52:23,623 --> 04:52:24,623 been changed, or let's say two to one, the\n 4464 04:52:24,623 --> 04:52:25,623 Also, you have the same option from above\n 4465 04:52:25,623 --> 04:52:26,623 change this to 212. Once again, one to one.\n 4466 04:52:26,623 --> 04:52:27,623 you can see the difference between this blueprint\n 4467 04:52:27,623 --> 04:52:28,623 the blueprint view, we are not rendering the\n 4468 04:52:28,623 --> 04:52:29,623 are not rendering our layout. It's very useful\n 4469 04:52:29,623 --> 04:52:30,623 especially if you do not have the required\n 4470 04:52:30,623 --> 04:52:31,623 large amount of RAM, you can always go off\n 4471 04:52:31,623 --> 04:52:32,623 this blueprint so that you have only the blueprint.\n 4472 04:52:32,623 --> 04:52:33,623 in the next video. First of all, we are going\n 4473 04:52:34,623 --> 04:52:35,623 In this video, we are going to talk about\n 4474 04:52:35,623 --> 04:52:36,623 a short video. As always, let's switch back\n 4475 04:52:36,623 --> 04:52:37,623 constraint layout to a relative layout. You\n 4476 04:52:37,623 --> 04:52:38,623 just more comfortable with this relative layout.\n 4477 04:52:38,623 --> 04:52:39,623 And let's create our image view. This time\n 4478 04:52:39,623 --> 04:52:40,623 the width and height, I'm going to put some\n 4479 04:52:40,623 --> 04:52:41,623 Right now, you cannot see any image in your\n 4480 04:52:41,623 --> 04:52:42,623 not have any placeholder. But you can see\n 4481 04:52:42,623 --> 04:52:43,623 have some placeholder you can say something\n 4482 04:52:43,623 --> 04:52:44,623 you can add a sub image from your project.\n 4483 04:52:44,623 --> 04:52:45,623 For example, in your driver folder, you have\n 4484 04:52:45,623 --> 04:52:46,623 that, for example. And as soon as I select\n 4485 04:52:46,623 --> 04:52:47,623 image in our preview. Later on, we will talk\n 4486 04:52:47,623 --> 04:52:48,623 that are related to images in Android projects.\n 4487 04:52:48,623 --> 04:52:49,623 if you want we can later on change this image\n 4488 04:52:49,623 --> 04:52:50,623 our image view. Let's say ID, let's name it\n 4489 04:52:50,623 --> 04:52:51,623 of our path. Let's say center your parent\n 4490 04:52:51,623 --> 04:52:52,623 image, we have used this app driver, which\n 4491 04:52:52,623 --> 04:52:53,623 lives in our driver folder. If you take a\n 4492 04:52:53,623 --> 04:52:54,623 folder, we have seen the layout folder in\n 4493 04:52:54,623 --> 04:52:55,623 But beside that we have this driver folder.\n 4494 04:52:55,623 --> 04:52:56,623 files as well. So if you take a look at this\n 4495 04:52:56,623 --> 04:52:57,623 have this XML file which at the end it result\n 4496 04:52:57,623 --> 04:52:58,623 Inside this XML file, we have some elements\n 4497 04:52:58,623 --> 04:52:59,623 about them yet. We will talk about them later\n 4498 04:52:59,623 --> 04:53:00,623 of this XML file is this driver in here. If\n 4499 04:53:00,623 --> 04:53:01,623 driver folder as well. For example, if you\n 4500 04:53:01,623 --> 04:53:02,623 new vector asset or image asset depending\n 4501 04:53:02,623 --> 04:53:03,623 select this new image asset. In here first\n 4502 04:53:03,623 --> 04:53:04,623 right now. It's launcher icons if you want\n 4503 04:53:04,623 --> 04:53:05,623 see action bar and tap icons. So basically\n 4504 04:53:05,623 --> 04:53:06,623 First of all, you need to name your icon.\n 4505 04:53:06,623 --> 04:53:07,623 you will pass to your images, for example,\n 4506 04:53:07,623 --> 04:53:08,623 passed this IC launcher background. That name\n 4507 04:53:08,623 --> 04:53:09,623 the convention to name your icons with this\n 4508 04:53:09,623 --> 04:53:10,623 in Android Studio, you have some icons. For\n 4509 04:53:10,623 --> 04:53:11,623 Android icon in here, you can see the clip\n 4510 04:53:11,623 --> 04:53:12,623 of icons, and you can use whichever you want.\n 4511 04:53:12,623 --> 04:53:13,623 under this Apache License, so make sure to\n 4512 04:53:13,623 --> 04:53:14,623 Because I've named this icon Ico alarm, I'm\n 4513 04:53:14,623 --> 04:53:15,623 this one, let's select okay. And in here,\n 4514 04:53:15,623 --> 04:53:16,623 void. If you want, you can change the color\n 4515 04:53:16,623 --> 04:53:17,623 color. For example, let's pass in black. 4516 04:53:17,623 --> 04:53:18,623 Now you can see the alarm better. Also notice\n 4517 04:53:18,623 --> 04:53:19,623 And that's because in different screen sizes,\n 4518 04:53:19,623 --> 04:53:20,623 of these sizes. For example, if it's a larger\n 4519 04:53:20,623 --> 04:53:21,623 select one of these larger images similar\n 4520 04:53:21,623 --> 04:53:22,623 on a smaller screen size device, the Android\n 4521 04:53:22,623 --> 04:53:23,623 Okay, let's select Next from here. Once again,\n 4522 04:53:23,623 --> 04:53:24,623 inside the driver folder, multiple images,\n 4523 04:53:24,623 --> 04:53:25,623 will be added. And you can also see the output\n 4524 04:53:25,623 --> 04:53:26,623 you create your driver file. Basically this\n 4525 04:53:26,623 --> 04:53:27,623 Let's click finish in here. And if you take\n 4526 04:53:27,623 --> 04:53:28,623 see that we have this icy alarm, which once\n 4527 04:53:28,623 --> 04:53:29,623 Now in our activity main dot XML file, instead\n 4528 04:53:29,623 --> 04:53:30,623 can pass IC Allah. So this way, by adding\n 4529 04:53:30,623 --> 04:53:31,623 add some images to your project. Similarly,\n 4530 04:53:31,623 --> 04:53:32,623 folder as well. Right now we have some images\n 4531 04:53:32,623 --> 04:53:33,623 And also we have this IC launcher around which\n 4532 04:53:33,623 --> 04:53:34,623 you want to add some extra images into your\n 4533 04:53:34,623 --> 04:53:35,623 you can add them into this magma folder. For\n 4534 04:53:35,623 --> 04:53:36,623 can copy that that's a copy. And in my micpa\n 4535 04:53:36,623 --> 04:53:37,623 directory. And also Let's name our file. It's\n 4536 04:53:37,623 --> 04:53:38,623 are importing some images into our project,\n 4537 04:53:38,623 --> 04:53:39,623 PNG or JPG file shouldn't have any spaces.\n 4538 04:53:39,623 --> 04:53:40,623 any awkward cases. So the naming here I think\n 4539 04:53:40,623 --> 04:53:41,623 this maker dot png has been added to my lead\n 4540 04:53:41,623 --> 04:53:42,623 my project, I can address that from inside\n 4541 04:53:42,623 --> 04:53:43,623 in here instead of saying iclm, I can say\n 4542 04:53:43,623 --> 04:53:44,623 our map folder, we are getting a red warning\n 4543 04:53:44,623 --> 04:53:45,623 I'm going to delete all of this. And I'm going\n 4544 04:53:45,623 --> 04:53:46,623 we can see that the logo has been added into\n 4545 04:53:46,623 --> 04:53:47,623 added these images and drivers in our project\n 4546 04:53:47,623 --> 04:53:48,623 project view. And let's see if we can locate\n 4547 04:53:48,623 --> 04:53:49,623 So you can guess that it's in our app folder\n 4548 04:53:49,623 --> 04:53:50,623 folder inside Resources folder, we can see\n 4549 04:53:50,623 --> 04:53:51,623 again, each one of these is going to respond\n 4550 04:53:51,623 --> 04:53:52,623 device. So for example, if we want to locate\n 4551 04:53:52,623 --> 04:53:53,623 image, I believe it will be inside this week\n 4552 04:53:53,623 --> 04:53:54,623 But if you want to have an application that\n 4553 04:53:54,623 --> 04:53:55,623 the screen qualities correctly, you need to\n 4554 04:53:55,623 --> 04:53:56,623 and add them into your project. Right now,\n 4555 04:53:56,623 --> 04:53:57,623 you can see that inside this folder, we do\n 4556 04:53:57,623 --> 04:53:58,623 to cause any problem in order to show the\n 4557 04:53:58,623 --> 04:53:59,623 as there is some image with the name maker\n 4558 04:53:59,623 --> 04:54:00,623 user, but it may cause some bad user experience.\n 4559 04:54:00,623 --> 04:54:01,623 And let's talk about how you can change the\n 4560 04:54:01,623 --> 04:54:02,623 let's quickly run the application. And let's\n 4561 04:54:02,623 --> 04:54:03,623 Right now you can see that the name of this\n 4562 04:54:03,623 --> 04:54:04,623 at the list of your applications on your device,\n 4563 04:54:04,623 --> 04:54:05,623 is this rounded Android icon. This is the\n 4564 04:54:05,623 --> 04:54:06,623 So if you take a look at your map folder 4565 04:54:06,623 --> 04:54:07,623 then in here we have this IC launcher round,\n 4566 04:54:07,623 --> 04:54:08,623 be somehow rounded. And if you want to change\n 4567 04:54:08,623 --> 04:54:09,623 can see that we have this Android manifest\n 4568 04:54:09,623 --> 04:54:10,623 see some general information about your application.\n 4569 04:54:10,623 --> 04:54:11,623 file and also other XML files in your project.\n 4570 04:54:11,623 --> 04:54:12,623 application tags, we have two attributes this\n 4571 04:54:12,623 --> 04:54:13,623 are addressing the IC launcher icon for now,\n 4572 04:54:13,623 --> 04:54:14,623 in the devices that you are not going to show\n 4573 04:54:14,623 --> 04:54:15,623 quickly change this one and let's address\n 4574 04:54:15,623 --> 04:54:16,623 I'm going to pass me but let's run the application.\n 4575 04:54:16,623 --> 04:54:17,623 successfully. If you take a look at the list\n 4576 04:54:17,623 --> 04:54:18,623 see that the icon for this images application\n 4577 04:54:18,623 --> 04:54:19,623 for this video. In the next video, we are\n 4578 04:54:19,623 --> 04:54:20,623 also a spinner. So in the next video, we are\n 4579 04:54:20,623 --> 04:54:21,623 items. See you in the next video. 4580 04:54:21,623 --> 04:54:22,623 In this video, we are going to talk about\n 4581 04:54:22,623 --> 04:54:23,623 in our application. For example, at least\n 4582 04:54:23,623 --> 04:54:24,623 students. For that, first of all, I'm going\n 4583 04:54:24,623 --> 04:54:25,623 is one of the options that we can use in order\n 4584 04:54:25,623 --> 04:54:26,623 first of all, I'm going to close this java\n 4585 04:54:26,623 --> 04:54:27,623 all, I'm going to delete this TextView. And\n 4586 04:54:27,623 --> 04:54:28,623 layout to a relative layout. If you want,\n 4587 04:54:28,623 --> 04:54:29,623 more comfortable with relative layout. After\n 4588 04:54:29,623 --> 04:54:30,623 For the bid standpoint. This time I'm going\n 4589 04:54:30,623 --> 04:54:31,623 you can see that in here in our preview, we\n 4590 04:54:31,623 --> 04:54:32,623 These are just some sample data indicating\n 4591 04:54:32,623 --> 04:54:33,623 going to add a margin top, let's say margin\n 4592 04:54:33,623 --> 04:54:34,623 an ID. But before that if you take a closer\n 4593 04:54:34,623 --> 04:54:35,623 see this scroll bar at the left pane in here,\n 4594 04:54:35,623 --> 04:54:36,623 in case if all of our items do not fit on\n 4595 04:54:36,623 --> 04:54:37,623 items, we can scroll over our list view. Okay,\n 4596 04:54:37,623 --> 04:54:38,623 ID. I'm going to name it cities ListView or\n 4597 04:54:38,623 --> 04:54:39,623 now. Let's quickly switch back to our Java\n 4598 04:54:39,623 --> 04:54:40,623 Like before above in here I'm going to say\n 4599 04:54:40,623 --> 04:54:41,623 or Let's name it cities list. down in here\n 4600 04:54:41,623 --> 04:54:42,623 city's list is equal to find view by ID. Also\n 4601 04:54:42,623 --> 04:54:43,623 this find view by ID method. Instead of typing\n 4602 04:54:43,623 --> 04:54:44,623 you press Enter or tab you will get the whole\n 4603 04:54:44,623 --> 04:54:45,623 shortcuts in IntelliJ and Android Studio later\n 4604 04:54:45,623 --> 04:54:46,623 of our ListView, let's say our.id dot cities\n 4605 04:54:46,623 --> 04:54:47,623 that we want to show in our list view. For\n 4606 04:54:47,623 --> 04:54:48,623 of different strings. And later on, I'm going\n 4607 04:54:48,623 --> 04:54:49,623 I'm going to say ArrayList. This one in here,\n 4608 04:54:49,623 --> 04:54:50,623 is equal to new ArrayList. And after that,\n 4609 04:54:50,623 --> 04:54:51,623 list, let's say cities dot add. And let's\nadd some items. 4610 04:54:51,623 --> 04:54:52,623 In here, I'm adding all of these cities to\n 4611 04:54:52,623 --> 04:54:53,623 cases, the list of your objects will be coming\n 4612 04:54:53,623 --> 04:54:54,623 Because we didn't talk about this stuff yet.\n 4613 04:54:54,623 --> 04:54:55,623 going to pass them manually to our ArrayList.\n 4614 04:54:55,623 --> 04:54:56,623 to pass this data to your ListView. But before\n 4615 04:54:56,623 --> 04:54:57,623 of the adapter is to fetch the data to your\n 4616 04:54:57,623 --> 04:54:58,623 our adapter. There are multiple kinds of adapters,\n 4617 04:54:58,623 --> 04:54:59,623 is this array adapter. This is the simplest\n 4618 04:54:59,623 --> 04:55:00,623 here. Let's say array adapter of type string.\n 4619 04:55:00,623 --> 04:55:01,623 to new array adapter. Inside the parentheses\n 4620 04:55:01,623 --> 04:55:02,623 First of all, we need a context, which I'm\n 4621 04:55:02,623 --> 04:55:03,623 we will talk about context. But in here, because\n 4622 04:55:03,623 --> 04:55:04,623 this main activity and activities are context.\n 4623 04:55:04,623 --> 04:55:05,623 So by passing this, we are passing our main\n 4624 04:55:05,623 --> 04:55:06,623 that yet. We will talk about context later\n 4625 04:55:06,623 --> 04:55:07,623 a layout file for every item in our list view.\n 4626 04:55:07,623 --> 04:55:08,623 name of a city, we need a layout for that\n 4627 04:55:08,623 --> 04:55:09,623 layout, but in here, I'm going to use one\n 4628 04:55:09,623 --> 04:55:10,623 to say Android dot r dot layout dot, let's\n 4629 04:55:10,623 --> 04:55:11,623 a built in layout file in which we can use\n 4630 04:55:11,623 --> 04:55:12,623 view. After passing the context, and also\n 4631 04:55:12,623 --> 04:55:13,623 to pass the data. In this case, we need to\n 4632 04:55:13,623 --> 04:55:14,623 in here. And now we have our adapter for our\n 4633 04:55:14,623 --> 04:55:15,623 adapter is to fetch the data, in this case,\n 4634 04:55:15,623 --> 04:55:16,623 creating your adapter, you can say city's\n 4635 04:55:16,623 --> 04:55:17,623 adapter, let's say city's adapter. before\n 4636 04:55:17,623 --> 04:55:18,623 what we are doing in here. First of all, we\n 4637 04:55:18,623 --> 04:55:19,623 file. After that we have initialized it inside\n 4638 04:55:19,623 --> 04:55:20,623 have prepared our data in this case, we have\n 4639 04:55:20,623 --> 04:55:21,623 strings called cities. After that we have\n 4640 04:55:21,623 --> 04:55:22,623 cities array list to our list view. And after\n 4641 04:55:22,623 --> 04:55:23,623 our list view. Let's quickly run our application.\n 4642 04:55:23,623 --> 04:55:24,623 our list view. As you can see, we have created\n 4643 04:55:24,623 --> 04:55:25,623 that we have passed in our ArrayList. Also,\n 4644 04:55:25,623 --> 04:55:26,623 screen, the ListView would be a scrollable\n 4645 04:55:26,623 --> 04:55:27,623 simple this item that we have passed in here.\n 4646 04:55:27,623 --> 04:55:28,623 press down the CTRL key in Mac it should be\n 4647 04:55:28,623 --> 04:55:29,623 list item one you can check the layout file.\n 4648 04:55:29,623 --> 04:55:30,623 some attributes. Nothing special in here.\n 4649 04:55:30,623 --> 04:55:31,623 now if you click on one item, nothing happens.\n 4650 04:55:31,623 --> 04:55:32,623 these items. Let's quickly see that. So after\n 4651 04:55:33,623 --> 04:55:34,623 dot set on item click listener this one. And\n 4652 04:55:34,623 --> 04:55:35,623 item click listener. Notice that it's adapter\n 4653 04:55:35,623 --> 04:55:36,623 from on click listener. When we pass this\n 4654 04:55:36,623 --> 04:55:37,623 in which has some inputs. The one that we\n 4655 04:55:37,623 --> 04:55:38,623 Basically, this is going to be the position\n 4656 04:55:38,623 --> 04:55:39,623 see how we can use that. For example in here\n 4657 04:55:39,623 --> 04:55:40,623 on each one of the items. Once again, when\n 4658 04:55:40,623 --> 04:55:41,623 we need to pass a context. Because we are\n 4659 04:55:41,623 --> 04:55:42,623 in another interface, we cannot simply pass\n 4660 04:55:42,623 --> 04:55:43,623 in order to refer to our context. After passing\n 4661 04:55:43,623 --> 04:55:44,623 text in here I'm going to say cities dot get.\n 4662 04:55:44,623 --> 04:55:45,623 position. So this way, we are going to get\n 4663 04:55:45,623 --> 04:55:46,623 are using this position as the index in order\n 4664 04:55:46,623 --> 04:55:47,623 cities ArrayList. Also, if you have noticed\n 4665 04:55:47,623 --> 04:55:48,623 click method, this final keyword has been\n 4666 04:55:48,623 --> 04:55:49,623 a reminder from the Java session, when you\n 4667 04:55:49,623 --> 04:55:50,623 a variable or an object, that variable or\n 4668 04:55:50,623 --> 04:55:51,623 it means that you cannot change that instance.\n 4669 04:55:51,623 --> 04:55:52,623 of this cities, after declaring it as final,\n 4670 04:55:52,623 --> 04:55:53,623 object. For example, we can use this dot add\n 4671 04:55:53,623 --> 04:55:54,623 inside this on item click method which exists\n 4672 04:55:54,623 --> 04:55:55,623 needs to be constant. And this final keyword\n 4673 04:55:55,623 --> 04:55:56,623 it right now from here, you can see that we\n 4674 04:55:56,623 --> 04:55:57,623 says that your variable should be constant.\n 4675 04:55:57,623 --> 04:55:58,623 Also, let's add another text in here, let's\n 4676 04:55:58,623 --> 04:55:59,623 once again. And let's see if we have set on\n 4677 04:55:59,623 --> 04:56:00,623 we click on one of the items inside our list\n 4678 04:56:00,623 --> 04:56:01,623 see the toast message in here, New York selected\n 4679 04:56:01,623 --> 04:56:02,623 our on item click listener is working fine.\n 4680 04:56:02,623 --> 04:56:03,623 different from the onClick. listener. If you\n 4681 04:56:03,623 --> 04:56:04,623 it's not going to work according to every\n 4682 04:56:04,623 --> 04:56:05,623 enough talking about ListView. You can work\n 4683 04:56:05,623 --> 04:56:06,623 suggest that because in Android, we have modern\n 4684 04:56:06,623 --> 04:56:07,623 options. For example, we have RecyclerView,\n 4685 04:56:07,623 --> 04:56:08,623 a look at your layout file inside the design\n 4686 04:56:08,623 --> 04:56:09,623 this legacy. You can see that in here. And\n 4687 04:56:09,623 --> 04:56:10,623 almost no one uses ListView. I just wanted\n 4688 04:56:10,623 --> 04:56:11,623 reason that you may want to avoid using ListView\n 4689 04:56:11,623 --> 04:56:12,623 For example, you cannot customize the layout\n 4690 04:56:12,623 --> 04:56:13,623 a customized layout for every item. But in\n 4691 04:56:13,623 --> 04:56:14,623 And also, the other issue is about performance.\n 4692 04:56:14,623 --> 04:56:15,623 want to show in a list for example, if you\n 4693 04:56:15,623 --> 04:56:16,623 see the performance issue when you're working\n 4694 04:56:16,623 --> 04:56:17,623 better job when it comes to performance. We\n 4695 04:56:17,623 --> 04:56:18,623 videos from now. But let's move on from this\n 4696 04:56:18,623 --> 04:56:19,623 to talk about is called a spinner. Let's quickly\n 4697 04:56:19,623 --> 04:56:20,623 this ListView. So in here, let's say a spinner.\n 4698 04:56:20,623 --> 04:56:21,623 say wrap content. Let's center it horizontally\n 4699 04:56:21,623 --> 04:56:22,623 horizontal through margin top, let's say 50\n 4700 04:56:22,623 --> 04:56:23,623 inside this preview very well. And that's\n 4701 04:56:23,623 --> 04:56:24,623 spinner yet. Basically, this is 4702 04:56:24,623 --> 04:56:25,623 Winner is going to create a drop down menu.\n 4703 04:56:25,623 --> 04:56:26,623 see a list of different options. We will see\n 4704 04:56:26,623 --> 04:56:27,623 just pass an ID for our spinner. Let's say\n 4705 04:56:27,623 --> 04:56:28,623 better name. Also, let's move our ListView\n 4706 04:56:28,623 --> 04:56:29,623 let's pass the ID of our spinner. Let's initialize\n 4707 04:56:29,623 --> 04:56:30,623 I'm going to come above in here and say, private\n 4708 04:56:30,623 --> 04:56:31,623 And then in here inside the onCreate method,\n 4709 04:56:31,623 --> 04:56:32,623 spinner is equal to find view by ID dot, let's\n 4710 04:56:32,623 --> 04:56:33,623 ListView, first of all, we need to create\n 4711 04:56:33,623 --> 04:56:34,623 show in our spinner. For that I'm going to\n 4712 04:56:34,623 --> 04:56:35,623 say array list of different strings. Let's\n 4713 04:56:35,623 --> 04:56:36,623 After that, let's pass on data to this students\nArrayList. 4714 04:56:36,623 --> 04:56:37,623 Similar to when we are working with listviews.\n 4715 04:56:37,623 --> 04:56:38,623 create an adapter. Once again, the purpose\n 4716 04:56:38,623 --> 04:56:39,623 data into our spinner, we can create our adapter\n 4717 04:56:39,623 --> 04:56:40,623 I can see array adapter of different strings.\n 4718 04:56:40,623 --> 04:56:41,623 to new array adapter. Like before, inside\n 4719 04:56:41,623 --> 04:56:42,623 of all, we need the context. After that, we\n 4720 04:56:42,623 --> 04:56:43,623 screener. Once again, you can create your\n 4721 04:56:43,623 --> 04:56:44,623 here for the sake of simplicity, I'm going\n 4722 04:56:44,623 --> 04:56:45,623 dot r dot layout dot the layout font that\n 4723 04:56:45,623 --> 04:56:46,623 spinner drop down item. When we created the\n 4724 04:56:46,623 --> 04:56:47,623 list item Vaughn. But in here we are going\n 4725 04:56:47,623 --> 04:56:48,623 After that, once again, we need our data which\n 4726 04:56:48,623 --> 04:56:49,623 After creating your adapter you can see the\n 4727 04:56:49,623 --> 04:56:50,623 you can pass your students adapter. Let's\n 4728 04:56:50,623 --> 04:56:51,623 spinner looks like. You can see this winner\n 4729 04:56:51,623 --> 04:56:52,623 down menu. If I click on this triangle in\n 4730 04:56:52,623 --> 04:56:53,623 that I have passed into my ArrayList. Once\n 4731 04:56:53,623 --> 04:56:54,623 For example, if I click on one of these, we\n 4732 04:56:54,623 --> 04:56:55,623 how can we create an onclicklistener for each\n 4733 04:56:55,623 --> 04:56:56,623 down in here, I'm going to say students spinner\n 4734 04:56:56,623 --> 04:56:57,623 different from the listener that we have used\n 4735 04:56:57,623 --> 04:56:58,623 used set on item click listener but it's not\n 4736 04:56:58,623 --> 04:56:59,623 to use this set on item selected listener.\n 4737 04:56:59,623 --> 04:57:00,623 item select listener adapter view.on item\n 4738 04:57:00,623 --> 04:57:01,623 to generate two methods on item selected and\n 4739 04:57:01,623 --> 04:57:02,623 on nothing selected means that if you do not\n 4740 04:57:02,623 --> 04:57:03,623 not going to work with this method and we\n 4741 04:57:03,623 --> 04:57:04,623 Instead inside this on item selected we are\n 4742 04:57:04,623 --> 04:57:05,623 you can see that we have this position in\n 4743 04:57:05,623 --> 04:57:06,623 example get the name of that student. First\n 4744 04:57:06,623 --> 04:57:07,623 we are inside another interface we are going\n 4745 04:57:07,623 --> 04:57:08,623 for the text I'm going to say students that\n 4746 04:57:09,623 --> 04:57:10,623 Let's run the application and let's see if\n 4747 04:57:10,623 --> 04:57:11,623 can see that even though I never clicked on\n 4748 04:57:11,623 --> 04:57:12,623 because we have used this set on item selected\n 4749 04:57:12,623 --> 04:57:13,623 the on item click listener. I don't know why.\n 4750 04:57:13,623 --> 04:57:14,623 the spinner, if you try to use that you will\n 4751 04:57:14,623 --> 04:57:15,623 that you have is this set on item selected\n 4752 04:57:15,623 --> 04:57:16,623 message. If we select another item, for example,\n 4753 04:57:16,623 --> 04:57:17,623 in here. This is one way of showing data inside\n 4754 04:57:17,623 --> 04:57:18,623 not know what data you're going to show. For\n 4755 04:57:18,623 --> 04:57:19,623 from a web server or a database, to be precise,\n 4756 04:57:19,623 --> 04:57:20,623 you know that data previously in case your\n 4757 04:57:20,623 --> 04:57:21,623 quickly see that. So before that, I'm going\n 4758 04:57:21,623 --> 04:57:22,623 inside this Resources folder, we have this\n 4759 04:57:22,623 --> 04:57:23,623 we have this strings dot XML file, we can\n 4760 04:57:23,623 --> 04:57:24,623 and later on, we can pass it into our espinar.\n 4761 04:57:24,623 --> 04:57:25,623 the place that we put all of the static strings.\n 4762 04:57:25,623 --> 04:57:26,623 have this app name string, in which we have\n 4763 04:57:26,623 --> 04:57:27,623 see that inside this Android manifest dot\n 4764 04:57:27,623 --> 04:57:28,623 we click on the label, you can see that it's\n 4765 04:57:28,623 --> 04:57:29,623 name of our string from strings that XML file,\n 4766 04:57:29,623 --> 04:57:30,623 is not going to change, for example, it's\n 4767 04:57:30,623 --> 04:57:31,623 or the web server. So we have passed it in\n 4768 04:57:31,623 --> 04:57:32,623 the usages of these strings that XML file\n 4769 04:57:32,623 --> 04:57:33,623 in our application. But for now, let's create\n 4770 04:57:33,623 --> 04:57:34,623 pass it to our spinner. So inside this strings\n 4771 04:57:34,623 --> 04:57:35,623 kinds of items, you can create a string, or\n 4772 04:57:35,623 --> 04:57:36,623 The way to do that is like this, you can say\n 4773 04:57:36,623 --> 04:57:37,623 For example, in here, I'm going to say to\n 4774 04:57:37,623 --> 04:57:38,623 closing tag, I can create different items,\n 4775 04:57:38,623 --> 04:57:39,623 I can provide the value for example, I can\n 4776 04:57:40,623 --> 04:57:41,623 Once again, don't worry, if you don't understand\n 4777 04:57:41,623 --> 04:57:42,623 about it in the next video. Now that we have\n 4778 04:57:42,623 --> 04:57:43,623 to our spinner item inside our activity main\n 4779 04:57:43,623 --> 04:57:44,623 you have an attribute called entries. This\n 4780 04:57:44,623 --> 04:57:45,623 these add airy students this is the address\n 4781 04:57:45,623 --> 04:57:46,623 file that's passed that and as soon as I pass\n 4782 04:57:46,623 --> 04:57:47,623 data in our spinner. So now that I have passed\n 4783 04:57:47,623 --> 04:57:48,623 don't need to pass them in my jar file dynamically.\n 4784 04:57:48,623 --> 04:57:49,623 of code, for example, from here to top in\n 4785 04:57:49,623 --> 04:57:50,623 inside this on item selected method. And that's\n 4786 04:57:50,623 --> 04:57:51,623 If you want to show the name of the student\n 4787 04:57:51,623 --> 04:57:52,623 the students array list, you can use another\n 4788 04:57:52,623 --> 04:57:53,623 create a new toast message. For the text.\n 4789 04:57:53,623 --> 04:57:54,623 dot let's say get selected item. You can see\n 4790 04:57:54,623 --> 04:57:55,623 let's say get selected item after that we\n 4791 04:57:55,623 --> 04:57:56,623 another level of conversion in order to convert\n 4792 04:57:56,623 --> 04:57:57,623 After that, let's say plus selected once again\n 4793 04:57:57,623 --> 04:57:58,623 what we have done. First of all we have created\n 4794 04:57:58,623 --> 04:57:59,623 it to our spinner statically and after that\n 4795 04:57:59,623 --> 04:58:00,623 set on item selected listener. Inside the\n 4796 04:58:00,623 --> 04:58:01,623 toast message. And we are getting the value\n 4797 04:58:01,623 --> 04:58:02,623 dot get selected item method. Let's run the\n 4798 04:58:02,623 --> 04:58:03,623 same behavior. You can see that we have some\n 4799 04:58:03,623 --> 04:58:04,623 example, you can see the toast message Brad\n 4800 04:58:04,623 --> 04:58:05,623 fine. So far, we have talked about different\n 4801 04:58:05,623 --> 04:58:06,623 dot XML, which is a layout file. In the next\n 4802 04:58:06,623 --> 04:58:07,623 of XML files, for example, this strings that\n 4803 04:58:07,623 --> 04:58:08,623 we have other kinds of XML files. In the next\n 4804 04:58:09,623 --> 04:58:10,623 So far, we have talked about different layout\n 4805 04:58:10,623 --> 04:58:11,623 Resources folder inside the layout folder.\n 4806 04:58:11,623 --> 04:58:12,623 main dot XML file, in which we have defined\n 4807 04:58:12,623 --> 04:58:13,623 activity. But in Android, there are a lot\n 4808 04:58:13,623 --> 04:58:14,623 of the previous video, we have take a look\n 4809 04:58:14,623 --> 04:58:15,623 days. Let's talk a bit about that strings\n 4810 04:58:15,623 --> 04:58:16,623 this Resources folder inside the values folder,\n 4811 04:58:16,623 --> 04:58:17,623 you remember, I said that this is the place\n 4812 04:58:17,623 --> 04:58:18,623 of your application. Let's quickly see what\n 4813 04:58:18,623 --> 04:58:19,623 layout file, if I define a TextView, we have\n 4814 04:58:19,623 --> 04:58:20,623 Let's say txt Hello, let's go to our Java\n 4815 04:58:20,623 --> 04:58:21,623 Let's say private TextView. Let's name it.\n 4816 04:58:21,623 --> 04:58:22,623 let's curricular initialize this TextView.\n 4817 04:58:22,623 --> 04:58:23,623 text of this text a fellow manually. For example,\n 4818 04:58:23,623 --> 04:58:24,623 And if we pass Hello, you can see that we\n 4819 04:58:24,623 --> 04:58:25,623 highlight says that this string cannot be\n 4820 04:58:25,623 --> 04:58:26,623 If you want, you can have some more information\n 4821 04:58:26,623 --> 04:58:27,623 you can press Ctrl plus f1. And you can see\n 4822 04:58:27,623 --> 04:58:28,623 this in here means that this text is going\n 4823 04:58:28,623 --> 04:58:29,623 example, if you have an application that has\n 4824 04:58:29,623 --> 04:58:30,623 going to be the same in all of the devices\n 4825 04:58:30,623 --> 04:58:31,623 warning says you can define this text inside\n 4826 04:58:31,623 --> 04:58:32,623 how we can use this strings dot XML file in\n 4827 04:58:32,623 --> 04:58:33,623 I'm going to define another string, the way\n 4828 04:58:33,623 --> 04:58:34,623 After that, we need to name our string. For\n 4829 04:58:34,623 --> 04:58:35,623 hello. And for the value of this string, I'm\n 4830 04:58:35,623 --> 04:58:36,623 to my text view inside my java file. Instead\n 4831 04:58:36,623 --> 04:58:37,623 string. This get a string method like this\n 4832 04:58:37,623 --> 04:58:38,623 every activity, we can use that because we\n 4833 04:58:38,623 --> 04:58:39,623 inside these practices, we can address our\n 4834 04:58:39,623 --> 04:58:40,623 string, dot let's say hello, right now the\n 4835 04:58:40,623 --> 04:58:41,623 example, we are just going to show hello to\n 4836 04:58:41,623 --> 04:58:42,623 is to create another strings dot XML file\n 4837 04:58:42,623 --> 04:58:43,623 here, I can right click on my values folder.\n 4838 04:58:43,623 --> 04:58:44,623 to name this new XML file exactly strings,\n 4839 04:58:44,623 --> 04:58:45,623 here it should be exactly the same. And in\n 4840 04:58:45,623 --> 04:58:46,623 about few of them in here. But the one that\n 4841 04:58:46,623 --> 04:58:47,623 Let's select that. And let's add it to this\n 4842 04:58:47,623 --> 04:58:48,623 is going to be useful for when you want to\n 4843 04:58:48,623 --> 04:58:49,623 For example, if you know that you have some\n 4844 04:58:49,623 --> 04:58:50,623 application this way for those users as well.\n 4845 04:58:51,623 --> 04:58:52,623 you can see that we have this the German D\n 4846 04:58:52,623 --> 04:58:53,623 we can select a specific region, we know that\n 4847 04:58:53,623 --> 04:58:54,623 let's select Germany. And let's press OK.\n 4848 04:58:54,623 --> 04:58:55,623 you can see that now you have these strings\n 4849 04:58:55,623 --> 04:58:56,623 dot XML file, the names are exactly the same,\n 4850 04:58:56,623 --> 04:58:57,623 users. Right now, this strings dot XML file\n 4851 04:58:57,623 --> 04:58:58,623 can define some strings in here. For example,\n 4852 04:58:58,623 --> 04:58:59,623 as well. Let's see a string. Let's name it\n 4853 04:58:59,623 --> 04:59:00,623 would be exactly the same name that you have\n 4854 04:59:00,623 --> 04:59:01,623 If you remember in here, we have this string\n 4855 04:59:01,623 --> 04:59:02,623 hello as well. Now let's pass on value for\n 4856 04:59:02,623 --> 04:59:03,623 of Hello is Hello, I believe. So inside this\n 4857 04:59:03,623 --> 04:59:04,623 we have a string called Hello. But the value\n 4858 04:59:04,623 --> 04:59:05,623 had inside the default strings dot XML. Now\n 4859 04:59:05,623 --> 04:59:06,623 file, because inside our main activity, we\n 4860 04:59:06,623 --> 04:59:07,623 addressing our Hello. If some German language\n 4861 04:59:07,623 --> 04:59:08,623 TextView will be different in different languages.\n 4862 04:59:08,623 --> 04:59:09,623 see the difference. Right now the language\n 4863 04:59:09,623 --> 04:59:10,623 that, we are seeing this Hello text. But if\n 4864 04:59:10,623 --> 04:59:11,623 say German, we should see how though, let's\n 4865 04:59:11,623 --> 04:59:12,623 change the language of this device. And let's\n 4866 04:59:12,623 --> 04:59:13,623 go to the settings. down in here inside the\n 4867 04:59:13,623 --> 04:59:14,623 input. Let's go to languages. And let's add\n 4868 04:59:14,623 --> 04:59:15,623 or its equivalent storage, we need to select\n 4869 04:59:15,623 --> 04:59:16,623 we need to make the storage as the default\n 4870 04:59:16,623 --> 04:59:17,623 to above this English. And now you can see\n 4871 04:59:17,623 --> 04:59:18,623 to Deutsch. If we run our application, once\n 4872 04:59:18,623 --> 04:59:19,623 time, you can see that we are seeing hollow\n 4873 04:59:19,623 --> 04:59:20,623 of code, we now have an application that looks\n 4874 04:59:20,623 --> 04:59:21,623 are the strings dot XML file is extremely\n 4875 04:59:21,623 --> 04:59:22,623 you can add another string file. For example,\n 4876 04:59:22,623 --> 04:59:23,623 click, we can say new value resource point.\n 4877 04:59:23,623 --> 04:59:24,623 again, we can select this locale. And if you\n 4878 04:59:24,623 --> 04:59:25,623 you can do the same process. After creating\n 4879 04:59:25,623 --> 04:59:26,623 your application for another language, you\n 4880 04:59:26,623 --> 04:59:27,623 a translator and ask him or her to change\n 4881 04:59:27,623 --> 04:59:28,623 As simple as that you can localize your application\n 4882 04:59:28,623 --> 04:59:29,623 we also have an error in here this URL is\n 4883 04:59:29,623 --> 04:59:30,623 do not have an equivalent string for this\n 4884 04:59:30,623 --> 04:59:31,623 in different languages as well. But we are\n 4885 04:59:31,623 --> 04:59:32,623 Okay, let's close all of these. And let's\n 4886 04:59:32,623 --> 04:59:33,623 applications. The other XML file that I'm\n 4887 04:59:33,623 --> 04:59:34,623 file. Once again, it's placed inside this\n 4888 04:59:34,623 --> 04:59:35,623 You See, that's right now we have three colors\n 4889 04:59:35,623 --> 04:59:36,623 the place that we pass all of our static colors.\n 4890 04:59:36,623 --> 04:59:37,623 here for that we can come between these resources\n 4891 04:59:37,623 --> 04:59:38,623 color. For example, let's say blue. And for\n 4892 04:59:38,623 --> 04:59:39,623 we can get that value by searching for HTML\n 4893 04:59:39,623 --> 04:59:40,623 For example, in here, if we want a blue color,\n 4894 04:59:40,623 --> 04:59:41,623 value from here and we can paste it in our\n 4895 04:59:41,623 --> 04:59:42,623 here we have this blue color. Now that we\n 4896 04:59:42,623 --> 04:59:43,623 places of our application. For example, inside\n 4897 04:59:43,623 --> 04:59:44,623 defined this TextView, we can change its color.\n 4898 04:59:44,623 --> 04:59:45,623 and we can address our color. For example,\n 4899 04:59:45,623 --> 04:59:46,623 is referencing our colors that XML file this\n 4900 04:59:46,623 --> 04:59:47,623 of our text has been changed to this light\n 4901 04:59:47,623 --> 04:59:48,623 on the internet, you can also define them\n 4902 04:59:48,623 --> 04:59:49,623 color accent color. Let's copy that. Let's\n 4903 04:59:49,623 --> 04:59:50,623 But for the value of this white color, I can\n 4904 04:59:50,623 --> 04:59:51,623 void color. For example, let's select this\n 4905 04:59:51,623 --> 04:59:52,623 color without searching the internet. We can\n 4906 04:59:52,623 --> 04:59:53,623 Okay, there is not much more to these colors\n 4907 04:59:53,623 --> 04:59:54,623 you can define new colors. Let's talk about\n 4908 04:59:54,623 --> 04:59:55,623 which is this styles dot XML. But before that,\n 4909 04:59:55,623 --> 04:59:56,623 styles dot XML. Once again, it lives inside\n 4910 04:59:56,623 --> 04:59:57,623 dot XML file is the place that we define the\n 4911 04:59:57,623 --> 04:59:58,623 one style in here. Later on, we will see that\n 4912 04:59:58,623 --> 04:59:59,623 style is app theme. But if we want we can\n 4913 04:59:59,623 --> 05:00:00,623 value of some of these colors if we want.\n 4914 05:00:00,623 --> 05:00:01,623 also define multiple styles. For example,\n 4915 05:00:01,623 --> 05:00:02,623 it down in here. We need to name our style\n 4916 05:00:03,623 --> 05:00:04,623 And let's override the previous style. For\n 4917 05:00:04,623 --> 05:00:05,623 here, which you can guess it's implementing\n 4918 05:00:05,623 --> 05:00:06,623 here. If you want, first of all, you can change\n 4919 05:00:06,623 --> 05:00:07,623 at the other ones. Let's say light.we have\n 4920 05:00:07,623 --> 05:00:08,623 to use in future videos, we have these dialogues,\n 4921 05:00:08,623 --> 05:00:09,623 instead, if you want, you can change some\n 4922 05:00:09,623 --> 05:00:10,623 parts of our application, we may use this\n 4923 05:00:10,623 --> 05:00:11,623 of this color primary is right now, this value\n 4924 05:00:11,623 --> 05:00:12,623 you want, you can change that, for example,\n 4925 05:00:12,623 --> 05:00:13,623 You can see that now the color primary in\n 4926 05:00:13,623 --> 05:00:14,623 one is this dark green for the second one\n 4927 05:00:14,623 --> 05:00:15,623 this customized app theme slide you can pass\n 4928 05:00:15,623 --> 05:00:16,623 application. It means that different activities\n 4929 05:00:16,623 --> 05:00:17,623 application can have different styles. For\n 4930 05:00:17,623 --> 05:00:18,623 some of them may not have that toolbar if\n 4931 05:00:18,623 --> 05:00:19,623 that how we can do that. Also we will talk\n 4932 05:00:19,623 --> 05:00:20,623 worry about activities if you don't understand\n 4933 05:00:20,623 --> 05:00:21,623 place that you define different styles for\n 4934 05:00:21,623 --> 05:00:22,623 this styles dot XML file later on. In the\n 4935 05:00:22,623 --> 05:00:23,623 design, but for now let's move on from this\n 4936 05:00:23,623 --> 05:00:24,623 The other XML file that I'm going to talk\n 4937 05:00:24,623 --> 05:00:25,623 manifest dot XML file. I believe this is the\n 4938 05:00:25,623 --> 05:00:26,623 Basically, this is where you define the general\n 4939 05:00:26,623 --> 05:00:27,623 you can see that we have this manifest tag.\n 4940 05:00:27,623 --> 05:00:28,623 we have seen this icon and round icon previously.\n 4941 05:00:28,623 --> 05:00:29,623 want to define different icons for your application.\n 4942 05:00:29,623 --> 05:00:30,623 the name of your application that is going\n 4943 05:00:30,623 --> 05:00:31,623 theme for your application, which as you can\n 4944 05:00:31,623 --> 05:00:32,623 style, if you want, you can pass your customized\n 4945 05:00:32,623 --> 05:00:33,623 in your application. But in here, I'm not\ngoing to do that. 4946 05:00:33,623 --> 05:00:34,623 Right now, inside the application tag, you\n 4947 05:00:34,623 --> 05:00:35,623 main activity. So basically, every activity\n 4948 05:00:35,623 --> 05:00:36,623 inside this application tag as well. This\n 4949 05:00:36,623 --> 05:00:37,623 because when we have created our application,\n 4950 05:00:37,623 --> 05:00:38,623 But if we don't select that template, one\n 4951 05:00:38,623 --> 05:00:39,623 inside this manifest file and declare our\n 4952 05:00:39,623 --> 05:00:40,623 this intent filter tag, don't worry about\n 4953 05:00:40,623 --> 05:00:41,623 in the course, I believe in the broadcast\n 4954 05:00:41,623 --> 05:00:42,623 you can guess the user of this intent filter\n 4955 05:00:42,623 --> 05:00:43,623 this main activity is the launcher activity\n 4956 05:00:43,623 --> 05:00:44,623 all of these yet. These are just some basic\n 4957 05:00:44,623 --> 05:00:45,623 So beside activities, you need to define three\n 4958 05:00:45,623 --> 05:00:46,623 So in every Android application, we have four\n 4959 05:00:46,623 --> 05:00:47,623 broadcast receivers, and services. We will\n 4960 05:00:47,623 --> 05:00:48,623 But these are the four main components of\n 4961 05:00:48,623 --> 05:00:49,623 to be declared inside the manifest file. So\n 4962 05:00:49,623 --> 05:00:50,623 important. It contains all of the important\n 4963 05:00:50,623 --> 05:00:51,623 back to this manifest file a lot during the\n 4964 05:00:51,623 --> 05:00:52,623 all of these new stuff that we are seeing\n 4965 05:00:52,623 --> 05:00:53,623 going to talk about is menus, let's quickly\n 4966 05:00:53,623 --> 05:00:54,623 inside the Resources folder, you can create\n 4967 05:00:54,623 --> 05:00:55,623 default, you do not have that directory like\n 4968 05:00:55,623 --> 05:00:56,623 files, we need to create that directory, we\n 4969 05:00:56,623 --> 05:00:57,623 can say new directory, it's very important\n 4970 05:00:57,623 --> 05:00:58,623 you can see that we have this menu folder\n 4971 05:00:58,623 --> 05:00:59,623 you can say new menu resource file. This way,\n 4972 05:00:59,623 --> 05:01:00,623 let's name this menu file main menu. Let's\n 4973 05:01:00,623 --> 05:01:01,623 it look like. Let's switch to text view. In\n 4974 05:01:01,623 --> 05:01:02,623 Basically menus are useful for when you want\n 4975 05:01:02,623 --> 05:01:03,623 And the way to do that is to come inside this\n 4976 05:01:03,623 --> 05:01:04,623 say item you can define multiple attributes\n 4977 05:01:04,623 --> 05:01:05,623 and you have to create that is this title.\n 4978 05:01:05,623 --> 05:01:06,623 can pass a title for your menu. For example,\n 4979 05:01:06,623 --> 05:01:07,623 some menu has been created in here. later\n 4980 05:01:07,623 --> 05:01:08,623 our main activity to have some sort of menu\n 4981 05:01:08,623 --> 05:01:09,623 that I have in here is ID for example, I can\n 4982 05:01:09,623 --> 05:01:10,623 for our menu item. But I believe we do not\n 4983 05:01:10,623 --> 05:01:11,623 An icon let's quickly create some icons in\n 4984 05:01:11,623 --> 05:01:12,623 create different icons, we can right click\n 4985 05:01:12,623 --> 05:01:13,623 we can create icons. In the icon type, I'm\n 4986 05:01:13,623 --> 05:01:14,623 example, inside this clip art, let's search\n 4987 05:01:14,623 --> 05:01:15,623 one icon in here, let's add that. Let's change\n 4988 05:01:15,623 --> 05:01:16,623 the color to black. Let's add another icon\n 4989 05:01:16,623 --> 05:01:17,623 before. Let's name this one icy alarm. 4990 05:01:17,623 --> 05:01:18,623 Let's search for alar. Color is fine, let's\n 4991 05:01:18,623 --> 05:01:19,623 two icons, we can pass them in our menu file.\n 4992 05:01:19,623 --> 05:01:20,623 Let's pass our settings icon icy settings.\n 4993 05:01:20,623 --> 05:01:21,623 in here. But if you want to see that you can\n 4994 05:01:21,623 --> 05:01:22,623 as action. So we have some values for this\n 4995 05:01:22,623 --> 05:01:23,623 it means that we always want our menu items\n 4996 05:01:23,623 --> 05:01:24,623 options. For example, we have this if row,\n 4997 05:01:24,623 --> 05:01:25,623 there is room for this menu item. We have\n 4998 05:01:25,623 --> 05:01:26,623 the menu items like this and never show them\n 4999 05:01:26,623 --> 05:01:27,623 now to always. And let's create another item\n 5000 05:01:27,623 --> 05:01:28,623 title is mandatory. And also we are getting\n 5001 05:01:28,623 --> 05:01:29,623 again, it says that you need to define the\n 5002 05:01:29,623 --> 05:01:30,623 this is for the localization purposes. And\n 5003 05:01:30,623 --> 05:01:31,623 title in your strings dot XML file. In your\n 5004 05:01:31,623 --> 05:01:32,623 But in here for the sake of simplicity, I'm\n 5005 05:01:32,623 --> 05:01:33,623 this warning. So let's pass a title in here.\n 5006 05:01:33,623 --> 05:01:34,623 Id let's say alarm menu. After that, let's\n 5007 05:01:34,623 --> 05:01:35,623 set the show as action attribute for this\n 5008 05:01:35,623 --> 05:01:36,623 you want. But I think for this simple menu\n 5009 05:01:36,623 --> 05:01:37,623 we have created this menu file, let's see\n 5010 05:01:37,623 --> 05:01:38,623 main activity. Let's close this file. Once\n 5011 05:01:38,623 --> 05:01:39,623 folder inside the menu directory that we just\n 5012 05:01:39,623 --> 05:01:40,623 main activity, you need to open the main activity\n 5013 05:01:40,623 --> 05:01:41,623 method in here. So because we are extending\n 5014 05:01:41,623 --> 05:01:42,623 we have some methods that we can override\n 5015 05:01:42,623 --> 05:01:43,623 If you come outside of this onCreate method\n 5016 05:01:43,623 --> 05:01:44,623 of all of the available methods you can see\n 5017 05:01:44,623 --> 05:01:45,623 we need in here is called on create Options\n 5018 05:01:45,623 --> 05:01:46,623 you can see this method in here let's select\n 5019 05:01:46,623 --> 05:01:47,623 of all I'm going to delete this statement\n 5020 05:01:47,623 --> 05:01:48,623 menu and I'm going to create or inflate my\n 5021 05:01:48,623 --> 05:01:49,623 class in here. Let's name it inflator is equal\n 5022 05:01:49,623 --> 05:01:50,623 is like this, find view by ID method. It's\n 5023 05:01:50,623 --> 05:01:51,623 with the help of this inflator, we are going\n 5024 05:01:51,623 --> 05:01:52,623 to our inflator we can say inflator dot inflate.\n 5025 05:01:52,623 --> 05:01:53,623 to address the menu font that we just created.\n 5026 05:01:53,623 --> 05:01:54,623 menu, the menu that we just created. The second\n 5027 05:01:54,623 --> 05:01:55,623 to this method. That's fast that you can see\n 5028 05:01:55,623 --> 05:01:56,623 This Boolean is indicating that if we have\n 5029 05:01:56,623 --> 05:01:57,623 we have inflated our menu and after that we\n 5030 05:01:57,623 --> 05:01:58,623 that we need in order to inflate or create\n 5031 05:01:58,623 --> 05:01:59,623 application. And let's see if we can see our\n 5032 05:01:59,623 --> 05:02:00,623 You can see that in our activity, we have\n 5033 05:02:00,623 --> 05:02:01,623 alarm icon. We can also set an onclicklistener\n 5034 05:02:01,623 --> 05:02:02,623 see how we can do that. So we need to override\n 5035 05:02:02,623 --> 05:02:03,623 menu method. If we press Ctrl plus Oh, and\n 5036 05:02:03,623 --> 05:02:04,623 this method in here if we select that, we\n 5037 05:02:04,623 --> 05:02:05,623 keep this super statement we will talk about\n 5038 05:02:05,623 --> 05:02:06,623 the input of this method, we are getting a\n 5039 05:02:06,623 --> 05:02:07,623 to click on. And we can use it. For example,\n 5040 05:02:07,623 --> 05:02:08,623 our switch statement. So our switch statement\n 5041 05:02:08,623 --> 05:02:09,623 ID. If you remember in our menu file for different\n 5042 05:02:09,623 --> 05:02:10,623 quickly see that in our main menu dot XML\n 5043 05:02:10,623 --> 05:02:11,623 items. And in here, we are going to act upon\n 5044 05:02:11,623 --> 05:02:12,623 Let's say in case it's our.id. That settings\n 5045 05:02:12,623 --> 05:02:13,623 let's say toast. For the text let's see settings\n 5046 05:02:13,623 --> 05:02:14,623 the toast message in here, instead of adding\n 5047 05:02:14,623 --> 05:02:15,623 specific case, we can return something. Once\n 5048 05:02:15,623 --> 05:02:16,623 this method is a Boolean as well. This Boolean\n 5049 05:02:16,623 --> 05:02:17,623 to this item successfully or not. In here,\n 5050 05:02:17,623 --> 05:02:18,623 to return true. So let's say return true.\n 5051 05:02:18,623 --> 05:02:19,623 in case it's our that Id does alarm menu.\n 5052 05:02:19,623 --> 05:02:20,623 message. Let's say alarm selected. In Here\n 5053 05:02:20,623 --> 05:02:21,623 world application, you may want to navigate\n 5054 05:02:21,623 --> 05:02:22,623 But more on that later on when we know about\n 5055 05:02:22,623 --> 05:02:23,623 showing the toast message, let's return through\n 5056 05:02:23,623 --> 05:02:24,623 case. In the default case, I am going to return\n 5057 05:02:24,623 --> 05:02:25,623 in other items besides these two. So do whatever\n 5058 05:02:25,623 --> 05:02:26,623 I can call this super segment from here, I\n 5059 05:02:26,623 --> 05:02:27,623 we run our application. Let's review what\n 5060 05:02:27,623 --> 05:02:28,623 on options item selected method we are getting\n 5061 05:02:28,623 --> 05:02:29,623 to create a switch statement. In case the\n 5062 05:02:29,623 --> 05:02:30,623 are showing this source message setting selected.\n 5063 05:02:30,623 --> 05:02:31,623 another toast message. But in the default\n 5064 05:02:31,623 --> 05:02:32,623 two, we are passing the job to the parent\n 5065 05:02:32,623 --> 05:02:33,623 see if we have set the listener successfully.\n 5066 05:02:33,623 --> 05:02:34,623 icon, you can see that settings selected.\n 5067 05:02:34,623 --> 05:02:35,623 selected. It seems like you have done a good\n 5068 05:02:35,623 --> 05:02:36,623 Okay, I think that's enough for this video.\n 5069 05:02:36,623 --> 05:02:37,623 our talk about other kinds of XML files available\n 5070 05:02:37,623 --> 05:02:38,623 Let's continue our talk about different XML\n 5071 05:02:38,623 --> 05:02:39,623 a look at different XML files for example\n 5072 05:02:39,623 --> 05:02:40,623 inside our mipmap folder. We have seen a strange\n 5073 05:02:40,623 --> 05:02:41,623 a look at menus and also our manifest file.\n 5074 05:02:41,623 --> 05:02:42,623 now our main activity has only one layout\n 5075 05:02:42,623 --> 05:02:43,623 want, you can create more layout files for\n 5076 05:02:43,623 --> 05:02:44,623 layout is for the portrait mode, if you want,\n 5077 05:02:44,623 --> 05:02:45,623 let's say landscape mode. If you don't know\n 5078 05:02:45,623 --> 05:02:46,623 let me quickly show that. So right now, this\n 5079 05:02:46,623 --> 05:02:47,623 the rotation of our device, and this is going\n 5080 05:02:47,623 --> 05:02:48,623 the rotation of this device. Let's go to the\n 5081 05:02:48,623 --> 05:02:49,623 this is the option, this auto rotate, we need\n 5082 05:02:49,623 --> 05:02:50,623 device, you can see that now we have a different\n 5083 05:02:50,623 --> 05:02:51,623 work. But if you have a complex lab file that\n 5084 05:02:51,623 --> 05:02:52,623 rotations, you need to create two separate\n 5085 05:02:52,623 --> 05:02:53,623 for the portrait mode and one for the landscape\n 5086 05:02:53,623 --> 05:02:54,623 another layout file for this main activity.\n 5087 05:02:54,623 --> 05:02:55,623 folder, I can right click by selecting new\n 5088 05:02:55,623 --> 05:02:56,623 file, or alternatively, inside this activity\n 5089 05:02:56,623 --> 05:02:57,623 on this icon, you can see that we have this\n 5090 05:02:57,623 --> 05:02:58,623 you can create a landscape variation for the\n 5091 05:02:58,623 --> 05:02:59,623 do that, I'm going to add another text. And\n 5092 05:02:59,623 --> 05:03:00,623 this layout file. So I'm going to move this\n 5093 05:03:00,623 --> 05:03:01,623 quickly add some constraints. As I mentioned\n 5094 05:03:01,623 --> 05:03:02,623 other, you can always select both elements.\n 5095 05:03:02,623 --> 05:03:03,623 to constraint and add constraint from here,\n 5096 05:03:03,623 --> 05:03:04,623 I'm going to add some margins of let's say\n 5097 05:03:04,623 --> 05:03:05,623 going to be the look of my application in\n 5098 05:03:05,623 --> 05:03:06,623 after each other vertically. But in the landscape\n 5099 05:03:06,623 --> 05:03:07,623 each other, let's quickly create a variation\n 5100 05:03:07,623 --> 05:03:08,623 create landscape variation, you can see that\n 5101 05:03:08,623 --> 05:03:09,623 inside the activity main folder, we have this\n 5102 05:03:09,623 --> 05:03:10,623 mode, and the other one, which is for the\n 5103 05:03:10,623 --> 05:03:11,623 change this landscape for example, I'm going\n 5104 05:03:11,623 --> 05:03:12,623 Let's delete all of the previous constraints.\n 5105 05:03:12,623 --> 05:03:13,623 this TextView the left constraint. Let's place\n 5106 05:03:13,623 --> 05:03:14,623 Also, another point in here that you may find\n 5107 05:03:14,623 --> 05:03:15,623 elements, for example, horizontally, you can\n 5108 05:03:15,623 --> 05:03:16,623 by right clicking on the item, and by going\n 5109 05:03:16,623 --> 05:03:17,623 you can center your items horizontally. So\n 5110 05:03:17,623 --> 05:03:18,623 mode, the layout for the landscape mode, and\n 5111 05:03:18,623 --> 05:03:19,623 mode. Now if I run my application, I should\n 5112 05:03:19,623 --> 05:03:20,623 landscape mode, the two texts are beside each\n 5113 05:03:20,623 --> 05:03:21,623 mode, the two texts are vertically after each\n 5114 05:03:21,623 --> 05:03:22,623 in here and selecting create landscape variation,\n 5115 05:03:22,623 --> 05:03:23,623 main activity. But this is not the only option.\n 5116 05:03:23,623 --> 05:03:24,623 if you want to activate a nice theme for your\n 5117 05:03:24,623 --> 05:03:25,623 quickly see how we can create that. So in\n 5118 05:03:25,623 --> 05:03:26,623 here I have all sorts of options. For example,\n 5119 05:03:26,623 --> 05:03:27,623 activity, we can select this night mode, we\n 5120 05:03:27,623 --> 05:03:28,623 night mode. That's a night. Let's create this\n 5121 05:03:28,623 --> 05:03:29,623 thing. Now inside this activity main folder\n 5122 05:03:29,623 --> 05:03:30,623 dot XML files, the middle one is for the night\n 5123 05:03:30,623 --> 05:03:31,623 example, you can change some colors, but I'm\n 5124 05:03:31,623 --> 05:03:32,623 to ignore this layout file for the night view.\n 5125 05:03:32,623 --> 05:03:33,623 for our activity. So once again, I can go\n 5126 05:03:33,623 --> 05:03:34,623 you can see that we have all sorts of options.\n 5127 05:03:34,623 --> 05:03:35,623 in which we can create different layers for\n 5128 05:03:35,623 --> 05:03:36,623 on the user's device. Let's add this to this\n 5129 05:03:36,623 --> 05:03:37,623 a number. For example, if we want our application\n 5130 05:03:37,623 --> 05:03:38,623 put 21 in here, and we can create the layout\n 5131 05:03:38,623 --> 05:03:39,623 inside activity main folder. Now we have this\n 5132 05:03:39,623 --> 05:03:40,623 for the version 21 of the API. This way, you\n 5133 05:03:40,623 --> 05:03:41,623 can change them if you want. Before I finish\n 5134 05:03:41,623 --> 05:03:42,623 point of XML files in Android. let's right\n 5135 05:03:42,623 --> 05:03:43,623 new layout resource file. And let's see what\n 5136 05:03:43,623 --> 05:03:44,623 XML file, I'm going to say trademark. And\n 5137 05:03:44,623 --> 05:03:45,623 to let's say, relative layout. Let's select\n 5138 05:03:45,623 --> 05:03:46,623 this TextView, you can see that we have this\n 5139 05:03:46,623 --> 05:03:47,623 whenever you want to reuse some layout file,\n 5140 05:03:47,623 --> 05:03:48,623 dot XML file in which I'm going to put an\n 5141 05:03:48,623 --> 05:03:49,623 creating this layout file, I can reuse this\n 5142 05:03:49,623 --> 05:03:50,623 in multiple activities of my application.\n 5143 05:03:50,623 --> 05:03:51,623 layout files. First of all, let's design this\n 5144 05:03:51,623 --> 05:03:52,623 TextView. Or before that let's define an image\nview 5145 05:03:52,623 --> 05:03:53,623 let's say 15. dp for the width and height.\nLet's give it an ID. 5146 05:03:53,623 --> 05:03:54,623 And for the placeholder, I'm not going to\n 5147 05:03:54,623 --> 05:03:55,623 I'm going to use this IC launcher background\n 5148 05:03:55,623 --> 05:03:56,623 define a TextView. In here, wrap content and\n 5149 05:03:56,623 --> 05:03:57,623 developed by me Sam. After that, let's move\n 5150 05:03:57,623 --> 05:03:58,623 let's say to the right of logo. Let's add\n 5151 05:03:58,623 --> 05:03:59,623 this text a little bit. Let's say italic,\n 5152 05:03:59,623 --> 05:04:00,623 this TextView. Right now the width and height\n 5153 05:04:00,623 --> 05:04:01,623 is match parent in here, I'm going to change\n 5154 05:04:01,623 --> 05:04:02,623 wrap content, you will see why when we use\n 5155 05:04:02,623 --> 05:04:03,623 another attribute for both of these elements.\n 5156 05:04:03,623 --> 05:04:04,623 for both of them, let's say through between\n 5157 05:04:04,623 --> 05:04:05,623 is our simple layout file. In here we are\n 5158 05:04:05,623 --> 05:04:06,623 If we want to show this layout file in multiple\n 5159 05:04:06,623 --> 05:04:07,623 include tag include tag is very useful for\n 5160 05:04:07,623 --> 05:04:08,623 don't want to write the exact same file twice.\n 5161 05:04:08,623 --> 05:04:09,623 file. And let's see how we can use that trademark.\n 5162 05:04:09,623 --> 05:04:10,623 to say include, and I can add a layout attribute.\n 5163 05:04:10,623 --> 05:04:11,623 file. In this case, it's at layer slash trade.\n 5164 05:04:11,623 --> 05:04:12,623 file inside this layout file. If you want,\n 5165 05:04:12,623 --> 05:04:13,623 can see that I can select this whole layout\n 5166 05:04:13,623 --> 05:04:14,623 my layout file, you can see that it won't\n 5167 05:04:14,623 --> 05:04:15,623 again at the top of my screen. And that's\n 5168 05:04:15,623 --> 05:04:16,623 height of this layout, right. The way to do\n 5169 05:04:16,623 --> 05:04:17,623 in here for my whole layout file, I need to\n 5170 05:04:17,623 --> 05:04:18,623 So for example for the layout, which I'm going\n 5171 05:04:18,623 --> 05:04:19,623 I'm going to say wrap content This way, you\n 5172 05:04:19,623 --> 05:04:20,623 file, we just need to override the width and\n 5173 05:04:20,623 --> 05:04:21,623 two more constraints. I can use this trademark\n 5174 05:04:21,623 --> 05:04:22,623 parts of my application that can be useful\n 5175 05:04:22,623 --> 05:04:23,623 tag, you may want another tag. Let's quickly\n 5176 05:04:23,623 --> 05:04:24,623 sometimes you may see merge this tagging here.\n 5177 05:04:24,623 --> 05:04:25,623 it's avoiding redundancy. Let's talk about\n 5178 05:04:25,623 --> 05:04:26,623 elements have no idea about about their parents,\n 5179 05:04:26,623 --> 05:04:27,623 used inside relative layout, a linear layout\n 5180 05:04:27,623 --> 05:04:28,623 they don't know about the parent, you can\n 5181 05:04:28,623 --> 05:04:29,623 in here. But if you know for sure that where\n 5182 05:04:29,623 --> 05:04:30,623 example, if you are going to use this layout\n 5183 05:04:30,623 --> 05:04:31,623 to write the linear layout. Once again, you\n 5184 05:04:31,623 --> 05:04:32,623 At the time of rendering your layout file,\n 5185 05:04:32,623 --> 05:04:33,623 two elements will be placed inside the parent\n 5186 05:04:33,623 --> 05:04:34,623 when you know for sure, that's where you're\n 5187 05:04:34,623 --> 05:04:35,623 tag can improve the performance when rendering\n 5188 05:04:35,623 --> 05:04:36,623 change this to a relative layout. Okay, I\n 5189 05:04:36,623 --> 05:04:37,623 XML files in Android, we have others as well,\n 5190 05:04:37,623 --> 05:04:38,623 course. But for now, I think it's enough.\n 5191 05:04:38,623 --> 05:04:39,623 the material design library, see you in the\nnext video. 5192 05:04:39,623 --> 05:04:40,623 In creating Android applications, designing\n 5193 05:04:40,623 --> 05:04:41,623 layout will impact the number of downloads\n 5194 05:04:41,623 --> 05:04:42,623 also it will impact the user's feedback. But\n 5195 05:04:42,623 --> 05:04:43,623 if you're like me if you are more interested\n 5196 05:04:43,623 --> 05:04:44,623 we have material design as a guideline for\n 5197 05:04:44,623 --> 05:04:45,623 Design also introduces some new components\n 5198 05:04:45,623 --> 05:04:46,623 check the material design website. And let's\n 5199 05:04:46,623 --> 05:04:47,623 website for material design is material that 5200 05:04:47,623 --> 05:04:48,623 if you go to this Developer tab in here, you\n 5201 05:04:48,623 --> 05:04:49,623 you can also use material design for iOS app\n 5202 05:04:49,623 --> 05:04:50,623 and also you can use it with hybrid development\n 5203 05:04:50,623 --> 05:04:51,623 As I said, Material Design consists of two\n 5204 05:04:51,623 --> 05:04:52,623 designing your applications. Also, besides\n 5205 05:04:52,623 --> 05:04:53,623 that you can use in your application, we will\n 5206 05:04:53,623 --> 05:04:54,623 But before that, if you take a look at this\n 5207 05:04:54,623 --> 05:04:55,623 to check the guidelines for typography theming,\n 5208 05:04:55,623 --> 05:04:56,623 if you take a look at this material design\n 5209 05:04:56,623 --> 05:04:57,623 guidelines. Basically these guidelines are\n 5210 05:04:57,623 --> 05:04:58,623 a beautiful application. Basically, these\n 5211 05:04:58,623 --> 05:04:59,623 to follow when you are designing different\n 5212 05:04:59,623 --> 05:05:00,623 and the guidelines. In here we are not going\n 5213 05:05:00,623 --> 05:05:01,623 to take a look at the components. If you go\n 5214 05:05:01,623 --> 05:05:02,623 we have a lot of components. We are familiar\n 5215 05:05:02,623 --> 05:05:03,623 we have seen different buttons and checkboxes.\n 5216 05:05:03,623 --> 05:05:04,623 that later on. We will see a lot of these\n 5217 05:05:04,623 --> 05:05:05,623 few components that we already know. For example,\n 5218 05:05:05,623 --> 05:05:06,623 this image, you can see that we have four\n 5219 05:05:06,623 --> 05:05:07,623 are somehow different from the buttons that\n 5220 05:05:07,623 --> 05:05:08,623 Basically, the main difference is in the styling\n 5221 05:05:08,623 --> 05:05:09,623 have all sorts of other components. For example,\n 5222 05:05:09,623 --> 05:05:10,623 We have also some documentation and guidelines\n 5223 05:05:10,623 --> 05:05:11,623 to check the guidelines for designing a checkbox,\n 5224 05:05:11,623 --> 05:05:12,623 can see some guidelines. So make sure to check\n 5225 05:05:12,623 --> 05:05:13,623 use these components in our applications.\n 5226 05:05:13,623 --> 05:05:14,623 this video, we are not going to vote with\n 5227 05:05:14,623 --> 05:05:15,623 we will be coming back to this web page and\n 5228 05:05:15,623 --> 05:05:16,623 of all, we are going to start with material\n 5229 05:05:16,623 --> 05:05:17,623 action button. This one in here. We will also\n 5230 05:05:17,623 --> 05:05:18,623 like a snack bars. Later on in the course\n 5231 05:05:18,623 --> 05:05:19,623 up bars, and also things like tab layouts\n 5232 05:05:19,623 --> 05:05:20,623 implement these maffeo buttons in our application.\n 5233 05:05:20,623 --> 05:05:21,623 in your application, you need to add a dependency\n 5234 05:05:21,623 --> 05:05:22,623 dependencies in our applications yet, but\n 5235 05:05:22,623 --> 05:05:23,623 I said that Gradle will combine all of the\n 5236 05:05:23,623 --> 05:05:24,623 the static resources in our application. And\n 5237 05:05:24,623 --> 05:05:25,623 the third party libraries that we use in our\n 5238 05:05:25,623 --> 05:05:26,623 are going to use in here and later on Gradle\n 5239 05:05:26,623 --> 05:05:27,623 is this material design. So we need to add\n 5240 05:05:27,623 --> 05:05:28,623 with the help of Gradle. In order to add the\n 5241 05:05:28,623 --> 05:05:29,623 Developer tab. After that, you can select\n 5242 05:05:29,623 --> 05:05:30,623 you can go to this getting started. And from\n 5243 05:05:30,623 --> 05:05:31,623 need. In this page, you can see a step by\n 5244 05:05:31,623 --> 05:05:32,623 design library into your project, make sure\n 5245 05:05:32,623 --> 05:05:33,623 what they are saying is that, first of all,\n 5246 05:05:33,623 --> 05:05:34,623 in your project. Let's see where that is in\n 5247 05:05:34,623 --> 05:05:35,623 Gradle script inside this build that Gradle.\n 5248 05:05:35,623 --> 05:05:36,623 repository, Google repositories has been added\n 5249 05:05:36,623 --> 05:05:37,623 projects. But if you don't see this Google\n 5250 05:05:37,623 --> 05:05:38,623 after adding the Google repository is to add\n 5251 05:05:38,623 --> 05:05:39,623 dependency from here, and you can add it to\n 5252 05:05:39,623 --> 05:05:40,623 need to go to this build that Gradle module\n 5253 05:05:40,623 --> 05:05:41,623 close this one. And let's also minimize all\n 5254 05:05:41,623 --> 05:05:42,623 inside these dependencies in here. For example,\n 5255 05:05:42,623 --> 05:05:43,623 other dependencies. Let's face that in here.\n 5256 05:05:43,623 --> 05:05:44,623 right now we have this version tag in here.\n 5257 05:05:44,623 --> 05:05:45,623 check the internet for the latest version\n 5258 05:05:45,623 --> 05:05:46,623 of Andrew the studio. Right now I'm getting\n 5259 05:05:46,623 --> 05:05:47,623 you can see that the latest version available\n 5260 05:05:47,623 --> 05:05:48,623 I'm going to say 1.1 point zero. After adding\n 5261 05:05:48,623 --> 05:05:49,623 sync now. And after that Gradle will download\n 5262 05:05:49,623 --> 05:05:50,623 library files from the internet. And it will\n 5263 05:05:50,623 --> 05:05:51,623 click on the sync. Now before that, make sure\n 5264 05:05:51,623 --> 05:05:52,623 somehow fast. And now we can use material\n 5265 05:05:52,623 --> 05:05:53,623 these dependencies, you can see that by default,\n 5266 05:05:53,623 --> 05:05:54,623 we have this constraint layout, we have these\n 5267 05:05:54,623 --> 05:05:55,623 these app compat dependencies which help backward\n 5268 05:05:55,623 --> 05:05:56,623 Okay, now that we have added this material\n 5269 05:05:56,623 --> 05:05:57,623 But before using them, I'm going to add a\n 5270 05:05:57,623 --> 05:05:58,623 that. Let's also enable this preview. And\n 5271 05:05:58,623 --> 05:05:59,623 So in here, I'm going to save button, let's\n 5272 05:06:00,623 --> 05:06:01,623 let's say Say hello. Let's also change this\n 5273 05:06:01,623 --> 05:06:02,623 let's center our button. You can see that\n 5274 05:06:02,623 --> 05:06:03,623 Now let's implement material theme. And let's\n 5275 05:06:03,623 --> 05:06:04,623 So for that, I'm going to open my project\n 5276 05:06:04,623 --> 05:06:05,623 folder inside the values folder, we have these\n 5277 05:06:05,623 --> 05:06:06,623 we have this app theme style in which its\n 5278 05:06:06,623 --> 05:06:07,623 here. If we want to implement Matthew, your\n 5279 05:06:07,623 --> 05:06:08,623 do that. And the theme in here is going to\n 5280 05:06:08,623 --> 05:06:09,623 another theme called theme dot material components\n 5281 05:06:09,623 --> 05:06:10,623 a look at that in a minute. But in here, I'm\n 5282 05:06:10,623 --> 05:06:11,623 components. So for that, I'm going to delete\n 5283 05:06:11,623 --> 05:06:12,623 of the values from inside these material components\n 5284 05:06:12,623 --> 05:06:13,623 the past theme of this afternoon. But right\n 5285 05:06:13,623 --> 05:06:14,623 XML file, you can see that we are getting\n 5286 05:06:14,623 --> 05:06:15,623 style of our button. This is good for a night\n 5287 05:06:15,623 --> 05:06:16,623 parents theme to a light theme so that we\n 5288 05:06:16,623 --> 05:06:17,623 here. And if we switch back to our activity\n 5289 05:06:17,623 --> 05:06:18,623 seeing this beautiful light theme out button\n 5290 05:06:18,623 --> 05:06:19,623 the font is somehow different. And also the\n 5291 05:06:19,623 --> 05:06:20,623 We didn't change anything for our button elements.\n 5292 05:06:20,623 --> 05:06:21,623 as the parent theme of our application, all\n 5293 05:06:21,623 --> 05:06:22,623 We can also customize this button for example,\n 5294 05:06:22,623 --> 05:06:23,623 button. But before that, let's quickly add\n 5295 05:06:23,623 --> 05:06:24,623 that XML I'm going to add a new color, let's\n 5296 05:06:24,623 --> 05:06:25,623 the name to let's say orange. For the value,\n 5297 05:06:25,623 --> 05:06:26,623 in our activity main dot XML file, if we want\n 5298 05:06:26,623 --> 05:06:27,623 to the orange, we can say background tint\n 5299 05:06:27,623 --> 05:06:28,623 orange color. We can also change the text\n 5300 05:06:28,623 --> 05:06:29,623 necessary, I just wanted to show you that\n 5301 05:06:29,623 --> 05:06:30,623 this color. As you saw on the material design\n 5302 05:06:30,623 --> 05:06:31,623 Let's see other slides as well. For example,\n 5303 05:06:31,623 --> 05:06:32,623 material button, you can see that we have\n 5304 05:06:32,623 --> 05:06:33,623 see that this is basically this style that\n 5305 05:06:33,623 --> 05:06:34,623 Let's remove that. And let's see others, we\n 5306 05:06:34,623 --> 05:06:35,623 button. If you take a look at that, you can\n 5307 05:06:35,623 --> 05:06:36,623 to some outline button. Sometimes this might\n 5308 05:06:36,623 --> 05:06:37,623 quickly see that. This is the one material\n 5309 05:06:37,623 --> 05:06:38,623 will change our button to a text button. Sometimes\n 5310 05:06:38,623 --> 05:06:39,623 with the default case. So I'm going to delete\n 5311 05:06:39,623 --> 05:06:40,623 that using material design is very easy. Basically,\n 5312 05:06:40,623 --> 05:06:41,623 our project inside this, like build that Gradle\n 5313 05:06:41,623 --> 05:06:42,623 we change the parent to this team, that material\n 5314 05:06:42,623 --> 05:06:43,623 all of the elements from inside the material\n 5315 05:06:43,623 --> 05:06:44,623 into your layout file, for example, a checkbox\n 5316 05:06:44,623 --> 05:06:45,623 design library will be used. Okay, let's move\n 5317 05:06:45,623 --> 05:06:46,623 of the components that we don't have in our\n 5318 05:06:46,623 --> 05:06:47,623 design library, the first of those components\n 5319 05:06:47,623 --> 05:06:48,623 floating action button. Let's delete this\n 5320 05:06:48,623 --> 05:06:49,623 button. So in here I can say floating action\n 5321 05:06:49,623 --> 05:06:50,623 we have this floating action button and we\n 5322 05:06:50,623 --> 05:06:51,623 Let's use the first one for the width and\n 5323 05:06:51,623 --> 05:06:52,623 as soon as I do that, you can see that we\n 5324 05:06:52,623 --> 05:06:53,623 action button is going to be floating on our\n 5325 05:06:53,623 --> 05:06:54,623 the page, if you want, you can change the\n 5326 05:06:54,623 --> 05:06:55,623 move it to down below in here. For that I\n 5327 05:06:55,623 --> 05:06:56,623 so far. For example, I can see a line parent\n 5328 05:06:56,623 --> 05:06:57,623 that as soon as I do that its location will\n 5329 05:06:57,623 --> 05:06:58,623 can also use another attribute called align\n 5330 05:06:58,623 --> 05:06:59,623 of our screen, let's say through and now you\n 5331 05:06:59,623 --> 05:07:00,623 margins. Let's say margin. In here, we have\n 5332 05:07:00,623 --> 05:07:01,623 Or alternatively, we can use this version.\n 5333 05:07:01,623 --> 05:07:02,623 will get a warning. Let's quickly use that.\n 5334 05:07:02,623 --> 05:07:03,623 here, I'm going to say 20 dP, you can see\n 5335 05:07:03,623 --> 05:07:04,623 at this, it says that it's better to use margin.\n 5336 05:07:04,623 --> 05:07:05,623 the languages it starts from right. So for\n 5337 05:07:05,623 --> 05:07:06,623 in that case, this floating action button\n 5338 05:07:06,623 --> 05:07:07,623 And if you add a margin, right, it's going\n 5339 05:07:07,623 --> 05:07:08,623 of the screen. For that reason. It's better\n 5340 05:07:08,623 --> 05:07:09,623 and let's fast 20 dP, you can see that we\n 5341 05:07:09,623 --> 05:07:10,623 need to add a margin button. That's a margin\n 5342 05:07:10,623 --> 05:07:11,623 add an icon for your floating action button\n 5343 05:07:11,623 --> 05:07:12,623 driver folder and let's add it for our floating\n 5344 05:07:12,623 --> 05:07:13,623 on our driver folder. Let's select action\n 5345 05:07:13,623 --> 05:07:14,623 sign in here. Let's search for add. And let's\n 5346 05:07:14,623 --> 05:07:15,623 And also, let's change the color. I'm not\n 5347 05:07:15,623 --> 05:07:16,623 I'm going to use this custom color. And I'm\n 5348 05:07:16,623 --> 05:07:17,623 is on white. So let's say choose, and let's\n 5349 05:07:17,623 --> 05:07:18,623 for your floating action button. But for some\n 5350 05:07:18,623 --> 05:07:19,623 which is the attribute to pass an icon for\n 5351 05:07:19,623 --> 05:07:20,623 I added this dependency in my project, I need\n 5352 05:07:20,623 --> 05:07:21,623 option is to rebuild my project. Or the better\n 5353 05:07:21,623 --> 05:07:22,623 your cache and restart Android Studio. 5354 05:07:22,623 --> 05:07:23,623 Let's select that, let's see, invalidate and\n 5355 05:07:23,623 --> 05:07:24,623 I can use the source attribute. So inside\n 5356 05:07:24,623 --> 05:07:25,623 source, this 100 source, and I can pass my\n 5357 05:07:25,623 --> 05:07:26,623 that, this icon will be added to my floating\n 5358 05:07:26,623 --> 05:07:27,623 the color of this floating action button.\n 5359 05:07:27,623 --> 05:07:28,623 color that we have defined a few minutes ago.\n 5360 05:07:28,623 --> 05:07:29,623 here, and I can pass color orange, you can\n 5361 05:07:29,623 --> 05:07:30,623 Also, you can see that we have some sort of\n 5362 05:07:30,623 --> 05:07:31,623 you want, you can also change that. The way\n 5363 05:07:31,623 --> 05:07:32,623 background tint. And this way, you can pass\n 5364 05:07:32,623 --> 05:07:33,623 pass avoid color. First of all, you can create\n 5365 05:07:33,623 --> 05:07:34,623 after that pass that or alternatively, you\n 5366 05:07:34,623 --> 05:07:35,623 directly in here. For example, I know that\n 5367 05:07:35,623 --> 05:07:36,623 pass that, you can see that we have a void\n 5368 05:07:36,623 --> 05:07:37,623 border of this floating action button is now\n 5369 05:07:37,623 --> 05:07:38,623 is for the background color of your floating\n 5370 05:07:38,623 --> 05:07:39,623 tint is for the border of your floating action\n 5371 05:07:39,623 --> 05:07:40,623 anything. Let's quickly see that you can see\n 5372 05:07:40,623 --> 05:07:41,623 repo color, and pass a color. For example,\n 5373 05:07:41,623 --> 05:07:42,623 color is the color of the floating action\n 5374 05:07:42,623 --> 05:07:43,623 application. And let's see that you can see\n 5375 05:07:43,623 --> 05:07:44,623 button at the bottom of our screen. And if\n 5376 05:07:44,623 --> 05:07:45,623 That white color is this rainbow color. Beside\n 5377 05:07:45,623 --> 05:07:46,623 of this top bar has changed as well. This\n 5378 05:07:46,623 --> 05:07:47,623 theme in our application. Later on, we will\n 5379 05:07:47,623 --> 05:07:48,623 we work with material design. We will implement\n 5380 05:07:48,623 --> 05:07:49,623 But for now let's talk more about this floating\n 5381 05:07:49,623 --> 05:07:50,623 for this button if you want as well. But for\n 5382 05:07:50,623 --> 05:07:51,623 action button inside our main activity dot\n 5383 05:07:51,623 --> 05:07:52,623 can say private floating action button, this\n 5384 05:07:52,623 --> 05:07:53,623 action button package. Let's name it FA B.\n 5385 05:07:53,623 --> 05:07:54,623 our on create method. Let's say FA v is equal\n 5386 05:07:54,623 --> 05:07:55,623 to give an ID to our floating action button.\n 5387 05:07:55,623 --> 05:07:56,623 ID, let's just name it FA B, let's say our.id\n 5388 05:07:56,623 --> 05:07:57,623 onclicklistener is fine in here. And we can\n 5389 05:07:57,623 --> 05:07:58,623 a toast message. Let's say fab clicked. Let's\n 5390 05:07:58,623 --> 05:07:59,623 the toast message. You can see that you're\n 5391 05:07:59,623 --> 05:08:00,623 There are also other ways of using this floating\n 5392 05:08:00,623 --> 05:08:01,623 use a combination of floating action button\n 5393 05:08:01,623 --> 05:08:02,623 see that we can implement a beautiful style\n 5394 05:08:02,623 --> 05:08:03,623 But more on that later on when we talk about\n 5395 05:08:03,623 --> 05:08:04,623 enough for this video. In the next video we\n 5396 05:08:04,623 --> 05:08:05,623 design library. We will talk about snack bars\n 5397 05:08:05,623 --> 05:08:06,623 In this video, we are going to talk about\n 5398 05:08:06,623 --> 05:08:07,623 those components is snack bar. Before we start\n 5399 05:08:07,623 --> 05:08:08,623 does it look like. So if you go to material\n 5400 05:08:08,623 --> 05:08:09,623 here, you can see a snack bar. Let's see that.\n 5401 05:08:09,623 --> 05:08:10,623 a lot like a toast message. But the style\n 5402 05:08:10,623 --> 05:08:11,623 the snack bar, you can have a button that\n 5403 05:08:11,623 --> 05:08:12,623 your snack bars to be indefinite, it means\n 5404 05:08:12,623 --> 05:08:13,623 clicks on this action. Also, you can style\n 5405 05:08:13,623 --> 05:08:14,623 change the color of this text and also the\n 5406 05:08:14,623 --> 05:08:15,623 later on in the course snack bars are extremely\n 5407 05:08:15,623 --> 05:08:16,623 In order to use the snack bars. First of all,\n 5408 05:08:16,623 --> 05:08:17,623 into your project. So let's go to this Developer\n 5409 05:08:17,623 --> 05:08:18,623 the documentation getting started. Let's copy\n 5410 05:08:18,623 --> 05:08:19,623 Gradle scripts build that Gradle. Let's quickly\n 5411 05:08:19,623 --> 05:08:20,623 hover over this, you will see the latest version,\n 5412 05:08:20,623 --> 05:08:21,623 dependency. First of all in my layout file,\n 5413 05:08:21,623 --> 05:08:22,623 add a button. And also beside that I'm going\n 5414 05:08:22,623 --> 05:08:23,623 of all, you may have noticed some changes\n 5415 05:08:23,623 --> 05:08:24,623 the previous video. That's because I have\n 5416 05:08:24,623 --> 05:08:25,623 differences. Don't worry about that we will\n 5417 05:08:25,623 --> 05:08:26,623 For this video, let's just implement our snack\n 5418 05:08:26,623 --> 05:08:27,623 Android Studio is that you no longer can see\n 5419 05:08:27,623 --> 05:08:28,623 want to go to your text, you can go to this\n 5420 05:08:28,623 --> 05:08:29,623 about these differences. Let's give an ID\n 5421 05:08:29,623 --> 05:08:30,623 going to name it parent. Later on in this\n 5422 05:08:30,623 --> 05:08:31,623 ID to this constraint layout. Let's also go\n 5423 05:08:31,623 --> 05:08:32,623 Before that let's delete this text here. Let's\n 5424 05:08:32,623 --> 05:08:33,623 its text. I'm going to change it to show snack\n 5425 05:08:33,623 --> 05:08:34,623 of my application so that we can see the material\n 5426 05:08:34,623 --> 05:08:35,623 previous video in our values folder inside\n 5427 05:08:35,623 --> 05:08:36,623 the panel theme here. I'm going to change\n 5428 05:08:36,623 --> 05:08:37,623 light. If you switch back to your layout file,\n 5429 05:08:37,623 --> 05:08:38,623 buttons in my java file. First of all, I'm\n 5430 05:08:38,623 --> 05:08:39,623 layout and also this button. Let's quickly\n 5431 05:08:39,623 --> 05:08:40,623 Let's name it parent. And also private button.\n 5432 05:08:40,623 --> 05:08:41,623 inside the onCreate method. Let's initialize\n 5433 05:08:41,623 --> 05:08:42,623 ID r.id. That parent potential snack bar is\n 5434 05:08:42,623 --> 05:08:43,623 its ID was button after that set onclicklistener\n 5435 05:08:43,623 --> 05:08:44,623 bar dot set onclicklistener new onclicklistener\n 5436 05:08:44,623 --> 05:08:45,623 So let's say show snack bar. Let's quickly\n 5437 05:08:45,623 --> 05:08:46,623 show snack bar. We don't need any input. 5438 05:08:46,623 --> 05:08:47,623 And here is how you can show snack what you\n 5439 05:08:47,623 --> 05:08:48,623 a new snack bar you can use this static make\n 5440 05:08:48,623 --> 05:08:49,623 This make method needs three inputs. First\n 5441 05:08:49,623 --> 05:08:50,623 layout that we are going to show our snack\n 5442 05:08:50,623 --> 05:08:51,623 is a constraint layout. And as you saw I have\n 5443 05:08:51,623 --> 05:08:52,623 the reason I gave an ID to my constraint layout.\n 5444 05:08:52,623 --> 05:08:53,623 I need to text that I want to show in my snack\n 5445 05:08:53,623 --> 05:08:54,623 a snack bar. The third parameter in here is\n 5446 05:08:54,623 --> 05:08:55,623 you want to show your a snack bar. And you\n 5447 05:08:55,623 --> 05:08:56,623 say, a snack bar, that you have three constants\n 5448 05:08:56,623 --> 05:08:57,623 also left indefinite. The long and short are\n 5449 05:08:57,623 --> 05:08:58,623 you will show your snack bar indefinitely,\n 5450 05:08:58,623 --> 05:08:59,623 on that action button. Let's select this one\n 5451 05:08:59,623 --> 05:09:00,623 you can call dot show method in order to show\n 5452 05:09:00,623 --> 05:09:01,623 simple snack bar. And we don't have any action\n 5453 05:09:01,623 --> 05:09:02,623 click on this button, we should see our snack\n 5454 05:09:02,623 --> 05:09:03,623 bar. And we don't have any action beside that\n 5455 05:09:03,623 --> 05:09:04,623 because we have past this length, indefinite\n 5456 05:09:04,623 --> 05:09:05,623 Let's quickly change this constant to length\n 5457 05:09:05,623 --> 05:09:06,623 we show our snack bar, you can see that it\n 5458 05:09:06,623 --> 05:09:07,623 now let's see how we can add an action to\n 5459 05:09:07,623 --> 05:09:08,623 to change this constant to left indefinite\n 5460 05:09:08,623 --> 05:09:09,623 going to call another method. That method\n 5461 05:09:09,623 --> 05:09:10,623 need a text in here, this is going to be the\n 5462 05:09:10,623 --> 05:09:11,623 you can say retry in here. After that you\n 5463 05:09:11,623 --> 05:09:12,623 listener. This is going to be an interface.\n 5464 05:09:12,623 --> 05:09:13,623 we want when the user clicks on this retry\n 5465 05:09:13,623 --> 05:09:14,623 going to show a toast message. Let's say retry\n 5466 05:09:14,623 --> 05:09:15,623 As you can see in here, now we have this retry\n 5467 05:09:15,623 --> 05:09:16,623 indefinite. But if we click on this retry,\n 5468 05:09:16,623 --> 05:09:17,623 we will see a toast message. Let's also see\n 5469 05:09:17,623 --> 05:09:18,623 two texts this retry and also the color of\n 5470 05:09:18,623 --> 05:09:19,623 again before the show method in here, I'm\n 5471 05:09:19,623 --> 05:09:20,623 set action text color in order to change the\n 5472 05:09:20,623 --> 05:09:21,623 pass your colors in two different ways. First\n 5473 05:09:21,623 --> 05:09:22,623 color resources, if you remember in your project\n 5474 05:09:22,623 --> 05:09:23,623 folder, you had these colors, that XML file\n 5475 05:09:23,623 --> 05:09:24,623 can address one of these corners inside your\n 5476 05:09:24,623 --> 05:09:25,623 get color. And after that our dot color dot\n 5477 05:09:25,623 --> 05:09:26,623 you have noticed, we have some colors that\n 5478 05:09:26,623 --> 05:09:27,623 You can see that we have these colors as well.\n 5479 05:09:27,623 --> 05:09:28,623 primary in here, you can see that we are getting\n 5480 05:09:28,623 --> 05:09:29,623 can use this method in API level 23. and higher.\n 5481 05:09:29,623 --> 05:09:30,623 without seeing this error. Let's we can see\nthat. 5482 05:09:30,623 --> 05:09:31,623 Let's say get resources. This phone dot let's\n 5483 05:09:31,623 --> 05:09:32,623 address your color, you can say our color,\n 5484 05:09:32,623 --> 05:09:33,623 see the other way. Instead of using the resources\n 5485 05:09:33,623 --> 05:09:34,623 for example, instead of this whole method\n 5486 05:09:34,623 --> 05:09:35,623 which is coming from Android dot graphics\n 5487 05:09:35,623 --> 05:09:36,623 color with the help of this color class. So\n 5488 05:09:36,623 --> 05:09:37,623 you can also use this class. Okay, now let's\n 5489 05:09:37,623 --> 05:09:38,623 of our snack. For that I can say that set\n 5490 05:09:38,623 --> 05:09:39,623 to pass a color you have two options. In this\n 5491 05:09:39,623 --> 05:09:40,623 yellow. Let's run the application and let's\n 5492 05:09:40,623 --> 05:09:41,623 or not. Let's show our snack bar. You can\n 5493 05:09:41,623 --> 05:09:42,623 And also the color of our action button is\n 5494 05:09:42,623 --> 05:09:43,623 the snack bar. Later on, we will use snack\n 5495 05:09:43,623 --> 05:09:44,623 component that I'm going to talk about is\n 5496 05:09:44,623 --> 05:09:45,623 does it look like in material that I have.\n 5497 05:09:45,623 --> 05:09:46,623 this cart, you can see your cart views. Let's\n 5498 05:09:46,623 --> 05:09:47,623 view looks like. You can use it to, for example,\n 5499 05:09:47,623 --> 05:09:48,623 you can mix UI elements in form of a cart.\n 5500 05:09:48,623 --> 05:09:49,623 for your cart view. Also, you can have some\n 5501 05:09:49,623 --> 05:09:50,623 shadow or elevation to be precise beside your\n 5502 05:09:50,623 --> 05:09:51,623 to implement the actions we will do that later\n 5503 05:09:51,623 --> 05:09:52,623 implement a simple cartoon in our application,\n 5504 05:09:52,623 --> 05:09:53,623 in our project, so we can add the cart view\n 5505 05:09:53,623 --> 05:09:54,623 close this style and colors. In my layout\n 5506 05:09:54,623 --> 05:09:55,623 below this button. Let's switch to the split\n 5507 05:09:55,623 --> 05:09:56,623 going to define my cart view, let's say material\n 5508 05:09:56,623 --> 05:09:57,623 view, you also have a native cards view. But\n 5509 05:09:57,623 --> 05:09:58,623 want to use the material card view, you can\n 5510 05:09:58,623 --> 05:09:59,623 the dependency from the Android x libraries\n 5511 05:09:59,623 --> 05:10:00,623 this material cart view. I'm going to enter\n 5512 05:10:00,623 --> 05:10:01,623 I'm going to say 100 dP, I think that's fine.\n 5513 05:10:01,623 --> 05:10:02,623 has an odd shape, I think it's better to change\n 5514 05:10:02,623 --> 05:10:03,623 I'm going to say card view. After that inside\n 5515 05:10:03,623 --> 05:10:04,623 But before that, let's quickly concentrate\n 5516 05:10:04,623 --> 05:10:05,623 of all, I'm going to define a relative layout.\n 5517 05:10:05,623 --> 05:10:06,623 parent, the parent is this card view. So we\n 5518 05:10:06,623 --> 05:10:07,623 inside this relative layout, I'm going to\n 5519 05:10:07,623 --> 05:10:08,623 put a TextView wrap content and wrap content.\n 5520 05:10:08,623 --> 05:10:09,623 text, let's just say hello. Let's also change\n 5521 05:10:09,623 --> 05:10:10,623 And let's pass both beside that let's increase\n 5522 05:10:10,623 --> 05:10:11,623 this TextView, I'm going to define an image\n 5523 05:10:11,623 --> 05:10:12,623 can have multiple UI elements for the width\n 5524 05:10:12,623 --> 05:10:13,623 for the height, let's say match parent, I'm\n 5525 05:10:13,623 --> 05:10:14,623 TextView. So let's say layout below. But before\n 5526 05:10:14,623 --> 05:10:15,623 Let's say ID. txt Hello. Let's also add a\n 5527 05:10:15,623 --> 05:10:16,623 margin top, let's say 10 dP centered horizontal\n 5528 05:10:16,623 --> 05:10:17,623 say source. I'm going to pass this IC luncheon.\n 5529 05:10:17,623 --> 05:10:18,623 the cardview. Beside that in their current\n 5530 05:10:18,623 --> 05:10:19,623 well. For example, if you want to make the\n 5531 05:10:19,623 --> 05:10:20,623 have this option corner radius, called corner\n 5532 05:10:20,623 --> 05:10:21,623 right now you may not see the difference.\n 5533 05:10:21,623 --> 05:10:22,623 the corner radius You can also change the\n 5534 05:10:22,623 --> 05:10:23,623 not enough. The other option that we have\n 5535 05:10:23,623 --> 05:10:24,623 give some 3d shape to our card, we have some\n 5536 05:10:24,623 --> 05:10:25,623 to say five up, you can also define this card\n 5537 05:10:25,623 --> 05:10:26,623 file. Let's quickly do that private cart view.\n 5538 05:10:26,623 --> 05:10:27,623 We have this card view which is coming from\n 5539 05:10:27,623 --> 05:10:28,623 material card view which is coming from the\n 5540 05:10:28,623 --> 05:10:29,623 going to use this material called view but\n 5541 05:10:29,623 --> 05:10:30,623 style. Let's name it card view. And down in\n 5542 05:10:30,623 --> 05:10:31,623 initialize it Let's quickly set an onclicklistener\n 5543 05:10:31,623 --> 05:10:32,623 Beside that, you can see that we have a lot\n 5544 05:10:32,623 --> 05:10:33,623 later on in the course, set onclicklistener.\n 5545 05:10:33,623 --> 05:10:34,623 the application. And let's see what does our\n 5546 05:10:34,623 --> 05:10:35,623 something like this, which is not that good.\n 5547 05:10:35,623 --> 05:10:36,623 We will do that later on in the course. Specifically\n 5548 05:10:36,623 --> 05:10:37,623 of recycler view and card view for its items\n 5549 05:10:37,623 --> 05:10:38,623 We will see that I believe in the next video.\n 5550 05:10:38,623 --> 05:10:39,623 corner radius and also we have this elevation\n 5551 05:10:39,623 --> 05:10:40,623 Beside that later on in the course, we will\n 5552 05:10:40,623 --> 05:10:41,623 That means that we will have some button in\n 5553 05:10:41,623 --> 05:10:42,623 on that view, expand our cart view and we\n 5554 05:10:42,623 --> 05:10:43,623 for our item in our cart view. Okay, I think\n 5555 05:10:43,623 --> 05:10:44,623 I just wanted to show you how you can create\n 5556 05:10:44,623 --> 05:10:45,623 In the next video, we are going to start talking\n 5557 05:10:45,623 --> 05:10:46,623 have seen list view for showing different\n 5558 05:10:46,623 --> 05:10:47,623 option to show lists of different items. In\n 5559 05:10:47,623 --> 05:10:48,623 to see how we can use recycler views. See\nyou in the next video. 5560 05:10:48,623 --> 05:10:49,623 In this video, we are going to talk about\n 5561 05:10:49,623 --> 05:10:50,623 option for showing a list of different items\n 5562 05:10:50,623 --> 05:10:51,623 can see, I've updated my Android Studio and\n 5563 05:10:51,623 --> 05:10:52,623 about recycler view, I'm going to show some\n 5564 05:10:52,623 --> 05:10:53,623 Android Studio, I strongly suggest that you\n 5565 05:10:53,623 --> 05:10:54,623 can do that by going to this Help menu. down\n 5566 05:10:54,623 --> 05:10:55,623 And if there is any updates available, you\n 5567 05:10:55,623 --> 05:10:56,623 in here is Firebase services, we are not going\n 5568 05:10:56,623 --> 05:10:57,623 you can see that I've also have some updates\n 5569 05:10:57,623 --> 05:10:58,623 update them after this video. But for now,\n 5570 05:10:58,623 --> 05:10:59,623 remember from the installation videos, I've\n 5571 05:10:59,623 --> 05:11:00,623 stable channel. If you're not sure about your\n 5572 05:11:00,623 --> 05:11:01,623 going to this file tab in here by going to\n 5573 05:11:01,623 --> 05:11:02,623 you can see that my updates are being checked\n 5574 05:11:02,623 --> 05:11:03,623 as well. These other channels are for preview\n 5575 05:11:03,623 --> 05:11:04,623 developers to check new features in Android\n 5576 05:11:04,623 --> 05:11:05,623 Android team. But for you for the starter,\n 5577 05:11:05,623 --> 05:11:06,623 a stable channel. The first thing that is\n 5578 05:11:06,623 --> 05:11:07,623 Studio is the way you go to full screen, you\n 5579 05:11:07,623 --> 05:11:08,623 menu. And by going to appearance. From here,\n 5580 05:11:08,623 --> 05:11:09,623 this option was somewhere down in here. Let's\n 5581 05:11:09,623 --> 05:11:10,623 you can probably see in here is this component\n 5582 05:11:10,623 --> 05:11:11,623 There are not much changes in here just this\n 5583 05:11:11,623 --> 05:11:12,623 above in here. You can see that down in here\n 5584 05:11:12,623 --> 05:11:13,623 mode. Instead of in here we have three options.\n 5585 05:11:13,623 --> 05:11:14,623 can also select this one to go to the text\n 5586 05:11:14,623 --> 05:11:15,623 splitter mode. As you can see, it acts like\n 5587 05:11:15,623 --> 05:11:16,623 view, but there is a difference. Before that\n 5588 05:11:16,623 --> 05:11:17,623 From here from inside this splitter view,\n 5589 05:11:17,623 --> 05:11:18,623 if I select this button, I can see the text\n 5590 05:11:18,623 --> 05:11:19,623 of this button and also I can see all of the\n 5591 05:11:19,623 --> 05:11:20,623 to be helpful, especially if you're using\n 5592 05:11:20,623 --> 05:11:21,623 to minimize this attribute pane. You You can\n 5593 05:11:21,623 --> 05:11:22,623 attributes, you can also enable this palette\n 5594 05:11:22,623 --> 05:11:23,623 layout elements. And you can drag them directly\n 5595 05:11:23,623 --> 05:11:24,623 Once again, this is going to be helpful if\n 5596 05:11:24,623 --> 05:11:25,623 thing that you can see in here is this resource\n 5597 05:11:25,623 --> 05:11:26,623 Studio 3.5. But there has been some improvements\n 5598 05:11:26,623 --> 05:11:27,623 this resource manager, you can see all of\n 5599 05:11:27,623 --> 05:11:28,623 Previously, if you wanted to see different\n 5600 05:11:28,623 --> 05:11:29,623 have go to this project training here. And\n 5601 05:11:29,623 --> 05:11:30,623 checked your drivers. Now with this resource\n 5602 05:11:30,623 --> 05:11:31,623 more easily. Also, beside that you can see\n 5603 05:11:31,623 --> 05:11:32,623 mipmaps, the strings, and also if you click\n 5604 05:11:32,623 --> 05:11:33,623 sorts of resources in your project. Also,\n 5605 05:11:33,623 --> 05:11:34,623 from here. For example, right now, in our\n 5606 05:11:34,623 --> 05:11:35,623 its source is this IC launcher background\n 5607 05:11:35,623 --> 05:11:36,623 to change this to this IC launcher mipmap\n 5608 05:11:36,623 --> 05:11:37,623 and we can paste it in here, you can see that\n 5609 05:11:37,623 --> 05:11:38,623 Similarly, we can do the same thing for the\n 5610 05:11:38,623 --> 05:11:39,623 resources, we have this app name string, we\n 5611 05:11:39,623 --> 05:11:40,623 Hello, we can see that the text has been changed.\n 5612 05:11:40,623 --> 05:11:41,623 this resource manager can be useful. The other\n 5613 05:11:41,623 --> 05:11:42,623 of Android Studio is the font of my code.\n 5614 05:11:42,623 --> 05:11:43,623 to change it to the previous font that we\n 5615 05:11:43,623 --> 05:11:44,623 go to this file inside the settings. You can\n 5616 05:11:44,623 --> 05:11:45,623 the font. For example, I think I'm going to\n 5617 05:11:45,623 --> 05:11:46,623 it is the previous font that we had when we\n 5618 05:11:46,623 --> 05:11:47,623 besides Android Studio, I've updated my Gradle\n 5619 05:11:47,623 --> 05:11:48,623 can go to your project menu, you can go to\n 5620 05:11:48,623 --> 05:11:49,623 about the Gradle. First of all, if you take\n 5621 05:11:49,623 --> 05:11:50,623 you can see that we have the latest version\n 5622 05:11:50,623 --> 05:11:51,623 if you go to this build dot Gradle project\n 5623 05:11:51,623 --> 05:11:52,623 latest Gradle tools version. So beside Android\n 5624 05:11:52,623 --> 05:11:53,623 you wouldn't see any difference when you update\n 5625 05:11:53,623 --> 05:11:54,623 fix some bugs, and also it may improve some\n 5626 05:11:54,623 --> 05:11:55,623 to keep everything updated when you're working\n 5627 05:11:55,623 --> 05:11:56,623 this part. And let's talk about recycler view\n 5628 05:11:56,623 --> 05:11:57,623 close this project. And I'm going to create\n 5629 05:11:57,623 --> 05:11:58,623 Studio project. Now that we have in here under\n 5630 05:11:58,623 --> 05:11:59,623 as well. For example inside this TV, you can\n 5631 05:11:59,623 --> 05:12:00,623 operating systems, or for different devices,\n 5632 05:12:00,623 --> 05:12:01,623 are not going to work with them. Like before\n 5633 05:12:01,623 --> 05:12:02,623 name this project recycler view. Or let's\n 5634 05:12:02,623 --> 05:12:03,623 that in here, we have this new option in here.\n 5635 05:12:03,623 --> 05:12:04,623 libraries. So basically, before Android x,\n 5636 05:12:04,623 --> 05:12:05,623 backward compatibility is in older devices.\n 5637 05:12:05,623 --> 05:12:06,623 of Android X was mandatory. But now in here\n 5638 05:12:06,623 --> 05:12:07,623 are going to use this legacy support libraries\n 5639 05:12:07,623 --> 05:12:08,623 this option. Okay, let's create our project. 5640 05:12:08,623 --> 05:12:09,623 And let's see how we can use recycler view.\n 5641 05:12:09,623 --> 05:12:10,623 we can go to our activity main dot XML file.\n 5642 05:12:10,623 --> 05:12:11,623 option in here but before using it, we need\n 5643 05:12:11,623 --> 05:12:12,623 You can click on this download option in here\n 5644 05:12:12,623 --> 05:12:13,623 gradle file. Or if you don't want to add it\n 5645 05:12:13,623 --> 05:12:14,623 view dependencies and add Manually into a\n 5646 05:12:14,623 --> 05:12:15,623 let's quickly open our Gradle scripts build\n 5647 05:12:15,623 --> 05:12:16,623 dependencies, you can see that we don't have\n 5648 05:12:16,623 --> 05:12:17,623 view by clicking on this. You can see a warning\n 5649 05:12:17,623 --> 05:12:18,623 say okay, it seems like we have added recycler\n 5650 05:12:18,623 --> 05:12:19,623 gradle file. And then in here, you can see\n 5651 05:12:19,623 --> 05:12:20,623 highlighting here, this is not the latest\n 5652 05:12:20,623 --> 05:12:21,623 to check the internet for the latest RecyclerView\n 5653 05:12:21,623 --> 05:12:22,623 you have version 1.1 point oh available. So\n 5654 05:12:22,623 --> 05:12:23,623 let's sync our project. Okay, now that we\n 5655 05:12:23,623 --> 05:12:24,623 can add it to our layout file. I'm going to\n 5656 05:12:24,623 --> 05:12:25,623 I'm going to minimize this resource manager.\n 5657 05:12:25,623 --> 05:12:26,623 layout to a relative layout. After that's\n 5658 05:12:26,623 --> 05:12:27,623 And let's add a recycler view. So you can\n 5659 05:12:27,623 --> 05:12:28,623 For the width and height. Let's say match\n 5660 05:12:28,623 --> 05:12:29,623 layout. Let's also give you an idea. Let's\n 5661 05:12:29,623 --> 05:12:30,623 I'm going to show a list of different contacts\n 5662 05:12:30,623 --> 05:12:31,623 creating our recycler view. And if you enable\n 5663 05:12:31,623 --> 05:12:32,623 you can see that we have these options inside\n 5664 05:12:32,623 --> 05:12:33,623 some padding to this parent relative layout.\n 5665 05:12:33,623 --> 05:12:34,623 say padding, and let's say 10 dP. That seems\n 5666 05:12:34,623 --> 05:12:35,623 our recycler view in our Java file. So inside\n 5667 05:12:35,623 --> 05:12:36,623 all, I'm going to say private recycler view.\n 5668 05:12:36,623 --> 05:12:37,623 view v jet. Let's name it contacts recycler\n 5669 05:12:37,623 --> 05:12:38,623 method, let's initialize it. Contacts, recycler\n 5670 05:12:38,623 --> 05:12:39,623 recycler view. When we have worked with ListView,\n 5671 05:12:39,623 --> 05:12:40,623 our ListView, we could have create an array\n 5672 05:12:40,623 --> 05:12:41,623 our array adapter to our list view. But when\n 5673 05:12:41,623 --> 05:12:42,623 our own adapter. Creating your own recycler\n 5674 05:12:42,623 --> 05:12:43,623 code that you have written so far. But we\n 5675 05:12:43,623 --> 05:12:44,623 Before creating our adapter. We also need\n 5676 05:12:44,623 --> 05:12:45,623 used ListView. For every item in our list\n 5677 05:12:45,623 --> 05:12:46,623 view, we need to create that layout as well.\n 5678 05:12:46,623 --> 05:12:47,623 folder inside the layout folder, I'm going\n 5679 05:12:47,623 --> 05:12:48,623 going to name this phone contacts this item.\n 5680 05:12:48,623 --> 05:12:49,623 to a relative layout. Okay, let's create our\n 5681 05:12:49,623 --> 05:12:50,623 If you remember from previous videos, I said\n 5682 05:12:50,623 --> 05:12:51,623 you have all sorts of flexibilities. In designing\n 5683 05:12:51,623 --> 05:12:52,623 at more complex layout files. But in here,\n 5684 05:12:52,623 --> 05:12:53,623 Let's switch to the split view so that we\n 5685 05:12:53,623 --> 05:12:54,623 Wrap content and wrap content. For the text,\n 5686 05:12:54,623 --> 05:12:55,623 view, we are going to change this text view.\n 5687 05:12:56,623 --> 05:12:57,623 let's say txt name. I'm also going to change\n 5688 05:12:57,623 --> 05:12:58,623 content because we don't want to occupy the\n 5689 05:12:58,623 --> 05:12:59,623 view. For that, let's change this font to\n 5690 05:12:59,623 --> 05:13:00,623 in here so that we can see it better. And\n 5691 05:13:00,623 --> 05:13:01,623 And that's past 10 Up. Sorry for that. Let's\n 5692 05:13:01,623 --> 05:13:02,623 will see how it can be useful. Let's just\n 5693 05:13:02,623 --> 05:13:03,623 be the layout file for every item in our recycler\n 5694 05:13:03,623 --> 05:13:04,623 this item dot XML file, we can create our\n 5695 05:13:04,623 --> 05:13:05,623 create a Java class in our project. So inside\n 5696 05:13:05,623 --> 05:13:06,623 Let's name this class contacts, recycler view\n 5697 05:13:06,623 --> 05:13:07,623 see what do we have in here. So first of all,\n 5698 05:13:07,623 --> 05:13:08,623 inner class inside this class, we will see\n 5699 05:13:08,623 --> 05:13:09,623 needs to be public, let's say public class.\n 5700 05:13:09,623 --> 05:13:10,623 the convention. This view holder class needs\n 5701 05:13:10,623 --> 05:13:11,623 class in here, but as you can see, we are\n 5702 05:13:11,623 --> 05:13:12,623 we need to create our constructor. Let's quickly\n 5703 05:13:12,623 --> 05:13:13,623 inner view holder class is going to hold the\n 5704 05:13:13,623 --> 05:13:14,623 For example, in this case, it's going to generate\n 5705 05:13:14,623 --> 05:13:15,623 we will see how we can use this layout file\n 5706 05:13:15,623 --> 05:13:16,623 So basically, this inner class is responsible\n 5707 05:13:16,623 --> 05:13:17,623 to have access to elements inside your view\n 5708 05:13:17,623 --> 05:13:18,623 this inner class. For example, in here, I\n 5709 05:13:18,623 --> 05:13:19,623 we had a TextView in our list item, the ID\n 5710 05:13:19,623 --> 05:13:20,623 down in here inside the constructor, let's\n 5711 05:13:20,623 --> 05:13:21,623 But because we are not inside an activity,\n 5712 05:13:21,623 --> 05:13:22,623 like this. Instead, what we can do is that\n 5713 05:13:22,623 --> 05:13:23,623 passed to this constructor. For example, I\n 5714 05:13:23,623 --> 05:13:24,623 can see that we have this method in here.\n 5715 05:13:24,623 --> 05:13:25,623 you can simply say find view by ID. But in\n 5716 05:13:25,623 --> 05:13:26,623 we can use this view or we can say item view\n 5717 05:13:26,623 --> 05:13:27,623 address our TextView I can see our.id dot\n 5718 05:13:27,623 --> 05:13:28,623 elements inside your layer file, you can add\n 5719 05:13:28,623 --> 05:13:29,623 later on in few minutes. But for now we are\n 5720 05:13:29,623 --> 05:13:30,623 minimize this. And now we can extend the RecyclerView\n 5721 05:13:30,623 --> 05:13:31,623 class. The way to do that is like this, we\n 5722 05:13:31,623 --> 05:13:32,623 we can see that we have this option. Also\n 5723 05:13:32,623 --> 05:13:33,623 view holder. If you import this adapter inside\n 5724 05:13:33,623 --> 05:13:34,623 There are also multiple view holders Make\n 5725 05:13:34,623 --> 05:13:35,623 class this orb that may code that your project\n 5726 05:13:35,623 --> 05:13:36,623 recycler view, so make sure to don't confuse\n 5727 05:13:36,623 --> 05:13:37,623 adapter for list views as the data type of\n 5728 05:13:37,623 --> 05:13:38,623 view holder class is exactly like that. And\n 5729 05:13:38,623 --> 05:13:39,623 at the end is this view holder class, the\n 5730 05:13:39,623 --> 05:13:40,623 Okay, now that we have extended recycler view\n 5731 05:13:40,623 --> 05:13:41,623 to be specific we need to implement some methods.\n 5732 05:13:41,623 --> 05:13:42,623 can see, we have three mandatory methods on\n 5733 05:13:42,623 --> 05:13:43,623 this get item count method. let's implement\n 5734 05:13:43,623 --> 05:13:44,623 a constructor for this adapter class. Let's\n 5735 05:13:44,623 --> 05:13:45,623 by going to construct it we can create our\n 5736 05:13:45,623 --> 05:13:46,623 methods in here, I'm going to create a model\n 5737 05:13:46,623 --> 05:13:47,623 video, I'm going to show some contacts inside\n 5738 05:13:47,623 --> 05:13:48,623 a model for those contacts. So inside my project,\n 5739 05:13:48,623 --> 05:13:49,623 name it contact. For this contact, I'm going\n 5740 05:13:49,623 --> 05:13:50,623 say private string name. After that, Let's\n 5741 05:13:50,623 --> 05:13:51,623 going to define a new string, let's say private\n 5742 05:13:51,623 --> 05:13:52,623 to be useful. Basically, we are going to show\n 5743 05:13:52,623 --> 05:13:53,623 URLs. And after that, we need to create our\n 5744 05:13:53,623 --> 05:13:54,623 insert, we can do that. Let's also create\n 5745 05:13:54,623 --> 05:13:55,623 I'm going to use all of them. later on. If\n 5746 05:13:55,623 --> 05:13:56,623 Let's also create a two string method this\n 5747 05:13:56,623 --> 05:13:57,623 our contact model. Let's close this class.\n 5748 05:13:57,623 --> 05:13:58,623 going to show a list of different contacts.\n 5749 05:13:58,623 --> 05:13:59,623 different contacts to this adapter class.\n 5750 05:13:59,623 --> 05:14:00,623 I'm going to create an ArrayList or to a specific\n 5751 05:14:00,623 --> 05:14:01,623 say private ArrayList of contacts, let's name\n 5752 05:14:01,623 --> 05:14:02,623 very important to initialize your ArrayList\n 5753 05:14:02,623 --> 05:14:03,623 get a nullpointerexception. Also, because\n 5754 05:14:03,623 --> 05:14:04,623 we also need to create a setter method so\n 5755 05:14:04,623 --> 05:14:05,623 main activity, we can set the initial data\n 5756 05:14:05,623 --> 05:14:06,623 the get item count method, I'm going to press\n 5757 05:14:06,623 --> 05:14:07,623 menu, we can create a setter for our contacts\n 5758 05:14:07,623 --> 05:14:08,623 activity, we will pass our data we're using\n 5759 05:14:08,623 --> 05:14:09,623 important point in here. Imagine that you\n 5760 05:14:09,623 --> 05:14:10,623 of your contacts from a web server from internet,\n 5761 05:14:10,623 --> 05:14:11,623 from the internet may change during the time,\n 5762 05:14:11,623 --> 05:14:12,623 recycler view should be changed as well. If\n 5763 05:14:12,623 --> 05:14:13,623 contacts method in order to change the data\n 5764 05:14:13,623 --> 05:14:14,623 the data inside your recycler view, you need\n 5765 05:14:14,623 --> 05:14:15,623 method. That method is called notify data\n 5766 05:14:15,623 --> 05:14:16,623 the data set for our adapter in this case\n 5767 05:14:16,623 --> 05:14:17,623 the list of different contacts at any time,\n 5768 05:14:17,623 --> 05:14:18,623 data set has been changed. This way we can\n 5769 05:14:18,623 --> 05:14:19,623 that we have received or passed to this adapter\n 5770 05:14:19,623 --> 05:14:20,623 And let's start working on these three different\n 5771 05:14:20,623 --> 05:14:21,623 this get item count, you can guess its purpose,\n 5772 05:14:21,623 --> 05:14:22,623 items in your adapter. In this case, we know\n 5773 05:14:22,623 --> 05:14:23,623 contacts. so we can simply return the list\n 5774 05:14:24,623 --> 05:14:25,623 That's all we need to do inside this get item\n 5775 05:14:25,623 --> 05:14:26,623 the number of items inside your adapter. And\n 5776 05:14:26,623 --> 05:14:27,623 I think that's enough for this video. In the\n 5777 05:14:27,623 --> 05:14:28,623 working on these two methods. After that,\n 5778 05:14:28,623 --> 05:14:29,623 layouts in recycler view. And after that we\n 5779 05:14:29,623 --> 05:14:30,623 order to show different contact images in\n 5780 05:14:31,623 --> 05:14:32,623 Okay, let's continue our talk about creating\n 5781 05:14:32,623 --> 05:14:33,623 let's quickly have a review of what we have\n 5782 05:14:33,623 --> 05:14:34,623 the RecyclerView dependency in our Gradle\n 5783 05:14:34,623 --> 05:14:35,623 module app inside these dependencies, you\n 5784 05:14:35,623 --> 05:14:36,623 After that we have added this recycler view\n 5785 05:14:36,623 --> 05:14:37,623 this relative layout, we have this recycler\n 5786 05:14:37,623 --> 05:14:38,623 dot java file. We have initialized our recycler\n 5787 05:14:38,623 --> 05:14:39,623 the layout file for every item in our recycler\n 5788 05:14:39,623 --> 05:14:40,623 layout file called contacts list item in our\n 5789 05:14:40,623 --> 05:14:41,623 look It's a simple relative layout, which\n 5790 05:14:41,623 --> 05:14:42,623 change this. After creating the layout file\n 5791 05:14:42,623 --> 05:14:43,623 adapter class. We have done that by adding\n 5792 05:14:43,623 --> 05:14:44,623 of that class was contacts recycler view adapter\n 5793 05:14:44,623 --> 05:14:45,623 this inner class, we have named it view holder\n 5794 05:14:45,623 --> 05:14:46,623 have extended the recycler view dot view holder.\n 5795 05:14:46,623 --> 05:14:47,623 this constructor in here. As I said in the\n 5796 05:14:47,623 --> 05:14:48,623 responsible for holding the view items for\n 5797 05:14:48,623 --> 05:14:49,623 instantiate all of our UI elements from inside\n 5798 05:14:49,623 --> 05:14:50,623 this view holder class if you want. After\n 5799 05:14:50,623 --> 05:14:51,623 class in here, we have extended the recycler\n 5800 05:14:51,623 --> 05:14:52,623 type, we have passed our inner view holder\n 5801 05:14:52,623 --> 05:14:53,623 adapter, we needed to implement three mandatory\n 5802 05:14:53,623 --> 05:14:54,623 view holder and get item count methods. We\n 5803 05:14:54,623 --> 05:14:55,623 video. But before that, we also created a\n 5804 05:14:55,623 --> 05:14:56,623 in our package. This contact has a name, an\n 5805 05:14:56,623 --> 05:14:57,623 this video, we will see that how we are going\n 5806 05:14:57,623 --> 05:14:58,623 creating our model inside our adapter class,\n 5807 05:14:58,623 --> 05:14:59,623 contexts in which we have named that contacts.\n 5808 05:14:59,623 --> 05:15:00,623 list I said that we are going to get a nullpointerexception\n 5809 05:15:00,623 --> 05:15:01,623 later on when we create an instance of this\n 5810 05:15:01,623 --> 05:15:02,623 So for that we have created this empty constructor.\n 5811 05:15:02,623 --> 05:15:03,623 in order to pass the data into this adapter\n 5812 05:15:03,623 --> 05:15:04,623 we have used this set contacts method in which\n 5813 05:15:04,623 --> 05:15:05,623 activity. After passing the data to this adapter,\n 5814 05:15:05,623 --> 05:15:06,623 set has changed so that we can refresh the\n 5815 05:15:06,623 --> 05:15:07,623 the previous video, we have talked about this\n 5816 05:15:07,623 --> 05:15:08,623 to return the number of items in our adapter.\n 5817 05:15:08,623 --> 05:15:09,623 array list dot size. Okay, now it's time to\n 5818 05:15:09,623 --> 05:15:10,623 let's close all of the extra classes and files. 5819 05:15:10,623 --> 05:15:11,623 And let's start working on this onCreate view\n 5820 05:15:11,623 --> 05:15:12,623 type of this method is a view holder. It means\n 5821 05:15:12,623 --> 05:15:13,623 our view holder to place to instantiate our\n 5822 05:15:13,623 --> 05:15:14,623 here. In order to create our view holder class.\n 5823 05:15:14,623 --> 05:15:15,623 We can do that by saying view this one in\n 5824 05:15:15,623 --> 05:15:16,623 were inside an activity, we could have said\n 5825 05:15:16,623 --> 05:15:17,623 a class beside our activity, we can't use\n 5826 05:15:17,623 --> 05:15:18,623 we can say layout inflator with capital L\n 5827 05:15:18,623 --> 05:15:19,623 that this from method is waiting for our context.\n 5828 05:15:19,623 --> 05:15:20,623 method that this is a static method. In here\n 5829 05:15:20,623 --> 05:15:21,623 this view group in order to get the context.\n 5830 05:15:21,623 --> 05:15:22,623 and I will talk about it. You can see that\n 5831 05:15:22,623 --> 05:15:23,623 can say parent dot get context. As you can\n 5832 05:15:23,623 --> 05:15:24,623 and we are using this layout inflator to generate\n 5833 05:15:24,623 --> 05:15:25,623 is that to inflate a layout for some reason\n 5834 05:15:25,623 --> 05:15:26,623 can say dot from and inside that method we\n 5835 05:15:26,623 --> 05:15:27,623 layout with the help of this layout inflator\n 5836 05:15:27,623 --> 05:15:28,623 after this Fromme method, we can say that\n 5837 05:15:28,623 --> 05:15:29,623 we can generate our view object. In here,\n 5838 05:15:29,623 --> 05:15:30,623 all, we need to pass the address of our layout\n 5839 05:15:30,623 --> 05:15:31,623 I mean that contacts list item, that XML file\n 5840 05:15:31,623 --> 05:15:32,623 our dot layout dot, let's say contact list\n 5841 05:15:32,623 --> 05:15:33,623 group, in this case, its name is parent, once\n 5842 05:15:33,623 --> 05:15:34,623 that, we need to pass a Boolean. I will talk\n 5843 05:15:34,623 --> 05:15:35,623 Let's fast forward. So in this case, and now\n 5844 05:15:35,623 --> 05:15:36,623 about these two arguments in here, this view\n 5845 05:15:36,623 --> 05:15:37,623 view group is the parent of all of the layout\n 5846 05:15:37,623 --> 05:15:38,623 layout, linear layout, and also constraint\n 5847 05:15:38,623 --> 05:15:39,623 different views inside it. If you want to\n 5848 05:15:39,623 --> 05:15:40,623 to your main activity just for testing purposes.\n 5849 05:15:40,623 --> 05:15:41,623 name with relative layout. from the previous\n 5850 05:15:41,623 --> 05:15:42,623 documentation in Android, we can press down\n 5851 05:15:42,623 --> 05:15:43,623 name, we can have access to the relative layout\n 5852 05:15:43,623 --> 05:15:44,623 you can see that this relative layout is extending\n 5853 05:15:44,623 --> 05:15:45,623 parent of all of our layout files. But why\n 5854 05:15:45,623 --> 05:15:46,623 arguments inside our adapter class. Before\n 5855 05:15:46,623 --> 05:15:47,623 line of code. We have created this just to\n 5856 05:15:47,623 --> 05:15:48,623 in here inside this inflate method, we are\n 5857 05:15:48,623 --> 05:15:49,623 that Where do you want to attach your view\n 5858 05:15:49,623 --> 05:15:50,623 of our adapter object from inside our main\n 5859 05:15:50,623 --> 05:15:51,623 files, we have defined a relative layout,\n 5860 05:15:51,623 --> 05:15:52,623 layout. And this view object in here, our\n 5861 05:15:52,623 --> 05:15:53,623 attached to that relative layout inside our\n 5862 05:15:53,623 --> 05:15:54,623 this view group has the name of parent in\n 5863 05:15:54,623 --> 05:15:55,623 can see that the name of this Boolean is attached\n 5864 05:15:55,623 --> 05:15:56,623 I just said that I want to attach my view\n 5865 05:15:56,623 --> 05:15:57,623 here because if we pass through, it will be\n 5866 05:15:57,623 --> 05:15:58,623 group as the parent of our view object. And\n 5867 05:15:58,623 --> 05:15:59,623 We have this Boolean because we can also pass\n 5868 05:15:59,623 --> 05:16:00,623 about our parent, and about where our view\n 5869 05:16:00,623 --> 05:16:01,623 view group, we can simply pass now, you can\n 5870 05:16:01,623 --> 05:16:02,623 to route. So if you passed now, you're not\n 5871 05:16:02,623 --> 05:16:03,623 view is going to be attached to. But of course,\n 5872 05:16:03,623 --> 05:16:04,623 I'm going to pass parent. And for the Boolean\n 5873 05:16:04,623 --> 05:16:05,623 this line of code with the help of this layout,\n 5874 05:16:05,623 --> 05:16:06,623 object. Now it's the time to create our view\n 5875 05:16:06,623 --> 05:16:07,623 if you take a look at the constructor of this\n 5876 05:16:07,623 --> 05:16:08,623 this constructor in here is accepting a view.\n 5877 05:16:08,623 --> 05:16:09,623 an instance of this view holder class. So\n 5878 05:16:10,623 --> 05:16:11,623 the one that exists in our adapter class,\n 5879 05:16:11,623 --> 05:16:12,623 view, let's say view holder, let's name it\n 5880 05:16:12,623 --> 05:16:13,623 first review. After that, let's return our\n 5881 05:16:13,623 --> 05:16:14,623 method in here this oncreateview holder is\n 5882 05:16:14,623 --> 05:16:15,623 for every item in our recycler view. Later\n 5883 05:16:15,623 --> 05:16:16,623 view holder method as you can see in here,\n 5884 05:16:16,623 --> 05:16:17,623 of our UI elements. Let's see how we can do\n 5885 05:16:17,623 --> 05:16:18,623 which I believe is the most important method\n 5886 05:16:18,623 --> 05:16:19,623 going to use the properties of our view holder\n 5887 05:16:19,623 --> 05:16:20,623 file, we have only one TextView. So if I want\n 5888 05:16:20,623 --> 05:16:21,623 something like this, I can say holder dot\n 5889 05:16:21,623 --> 05:16:22,623 text. You can see that in here we are able\n 5890 05:16:22,623 --> 05:16:23,623 Inside our view holder class, we had such\n 5891 05:16:23,623 --> 05:16:24,623 If you remember from the Java session, I said\n 5892 05:16:24,623 --> 05:16:25,623 the parent class, you can have access to all\n 5893 05:16:25,623 --> 05:16:26,623 inner class. In this case, inside this adapter\n 5894 05:16:26,623 --> 05:16:27,623 even though it's private. Okay, but what do\n 5895 05:16:27,623 --> 05:16:28,623 can see, beside this folder, we also are getting\n 5896 05:16:28,623 --> 05:16:29,623 like the position that we have inside ListView\n 5897 05:16:29,623 --> 05:16:30,623 of the item in our recycler view. Once again,\n 5898 05:16:30,623 --> 05:16:31,623 data for example from our contacts ArrayList.\n 5899 05:16:31,623 --> 05:16:32,623 can say contacts, dot, let's say get. And\n 5900 05:16:32,623 --> 05:16:33,623 Also, during the time, I've seen that the\n 5901 05:16:33,623 --> 05:16:34,623 it was named it sometimes it was position\n 5902 05:16:34,623 --> 05:16:35,623 this integer is just the position of every\n 5903 05:16:35,623 --> 05:16:36,623 after getting the corresponding contacts,\n 5904 05:16:36,623 --> 05:16:37,623 to set the name of our contact to this TextView.\n 5905 05:16:37,623 --> 05:16:38,623 view that you can create. You can have all\n 5906 05:16:38,623 --> 05:16:39,623 layout file, and after that inside this unbind\n 5907 05:16:39,623 --> 05:16:40,623 onClick listeners for each one of you I elements.\n 5908 05:16:40,623 --> 05:16:41,623 time, our adapter class is ready, we have\n 5909 05:16:41,623 --> 05:16:42,623 view adapter class. Now that we have created\n 5910 05:16:42,623 --> 05:16:43,623 back to our main activity and pass some data\n 5911 05:16:43,623 --> 05:16:44,623 method, we have instantiated a recycler view.\n 5912 05:16:44,623 --> 05:16:45,623 of different contacts. For example, let's\n 5913 05:16:45,623 --> 05:16:46,623 name it contacts is equal to new ArrayList.\n 5914 05:16:46,623 --> 05:16:47,623 in here because we don't know anything about\n 5915 05:16:47,623 --> 05:16:48,623 application, these data are probably coming\n 5916 05:16:48,623 --> 05:16:49,623 add some data to our contacts ArrayList. 5917 05:16:49,623 --> 05:16:50,623 As you can see, I've added some contacts into\n 5918 05:16:50,623 --> 05:16:51,623 a name also an email. And beside that I've\n 5919 05:16:51,623 --> 05:16:52,623 is just one point in here. And that's regarding\n 5920 05:16:52,623 --> 05:16:53,623 the address of some image from the internet,\n 5921 05:16:53,623 --> 05:16:54,623 example, like this dot jpg, or dot png. Those\n 5922 05:16:54,623 --> 05:16:55,623 So make sure to select the images that have\n 5923 05:16:55,623 --> 05:16:56,623 because some students asked me before how\n 5924 05:16:56,623 --> 05:16:57,623 quickly show you one example. For example,\n 5925 05:16:57,623 --> 05:16:58,623 images. And by right clicking on the image,\n 5926 05:16:58,623 --> 05:16:59,623 in another tab, you can paste that address\n 5927 05:16:59,623 --> 05:17:00,623 good to go. Okay, after creating your contacts,\n 5928 05:17:00,623 --> 05:17:01,623 For that, I'm going to say contact recycler\n 5929 05:17:01,623 --> 05:17:02,623 to new contacts recycler view adapter. We\n 5930 05:17:02,623 --> 05:17:03,623 so you're good to go. After that, we can use\n 5931 05:17:03,623 --> 05:17:04,623 say adapter dot set contacts, and we can pass\n 5932 05:17:04,623 --> 05:17:05,623 instance, and setting the data, we can set\n 5933 05:17:05,623 --> 05:17:06,623 in here, I can say contacts recycler view\n 5934 05:17:06,623 --> 05:17:07,623 in a ListView. That would be the end of everything.\n 5935 05:17:07,623 --> 05:17:08,623 in recycler view, there is also one more step.\n 5936 05:17:08,623 --> 05:17:09,623 recycler view as well. Let's quickly set that\n 5937 05:17:09,623 --> 05:17:10,623 RecyclerView dot set layout manager. In here\n 5938 05:17:10,623 --> 05:17:11,623 pass a linear layout manager and we can pass\n 5939 05:17:11,623 --> 05:17:12,623 in which for its constructor, we need the\n 5940 05:17:12,623 --> 05:17:13,623 activity, we can safely pass this as the context.\n 5941 05:17:13,623 --> 05:17:14,623 view to a linear layout manager. We are saying\n 5942 05:17:14,623 --> 05:17:15,623 in a linear fashion. The other option that\n 5943 05:17:15,623 --> 05:17:16,623 a look at that. But in here, this linear layout\n 5944 05:17:16,623 --> 05:17:17,623 to change that, for example, if you want to\n 5945 05:17:17,623 --> 05:17:18,623 will do that in a minute after running our\n 5946 05:17:18,623 --> 05:17:19,623 is ready to test. We have created our recycler\n 5947 05:17:19,623 --> 05:17:20,623 also have created this dynamic list of contacts.\n 5948 05:17:20,623 --> 05:17:21,623 class. We have set the data inside this adapter\n 5949 05:17:21,623 --> 05:17:22,623 to a recycler view. We also have set a layout\n 5950 05:17:22,623 --> 05:17:23,623 the application. And let's see what does a\n 5951 05:17:23,623 --> 05:17:24,623 list of different contacts name are being\n 5952 05:17:24,623 --> 05:17:25,623 If I had more contacts, I could have scrolled\n 5953 05:17:25,623 --> 05:17:26,623 all of them. Right now they all can fit on\n 5954 05:17:26,623 --> 05:17:27,623 Let's quickly change this linear layer to\n 5955 05:17:27,623 --> 05:17:28,623 So in order to have a horizontal linear layout,\n 5956 05:17:28,623 --> 05:17:29,623 manager dot horizontal, this one in here.\n 5957 05:17:29,623 --> 05:17:30,623 order to have a linear layout manager. Beside\n 5958 05:17:30,623 --> 05:17:31,623 pass that I'm going to pass false. As you\n 5959 05:17:31,623 --> 05:17:32,623 layout. If you want to reverse the order of\n 5960 05:17:32,623 --> 05:17:33,623 through in here. But I don't see any reason\n 5961 05:17:33,623 --> 05:17:34,623 Let's run the application once again. And\n 5962 05:17:34,623 --> 05:17:35,623 looks like. You can see that this time right\n 5963 05:17:35,623 --> 05:17:36,623 screen. And that's because when we created\n 5964 05:17:36,623 --> 05:17:37,623 view, we have past match parent as the width\n 5965 05:17:37,623 --> 05:17:38,623 items, you can scroll the window horizontally,\n 5966 05:17:38,623 --> 05:17:39,623 So this is what this horizontal linear layout\nlooks like. 5967 05:17:40,623 --> 05:17:41,623 quickly see the other layout manager that\n 5968 05:17:41,623 --> 05:17:42,623 one. The name of the other layout manager\n 5969 05:17:42,623 --> 05:17:43,623 all of these. And inside this set layout manager\n 5970 05:17:43,623 --> 05:17:44,623 For the inputs of this constructor, we need\n 5971 05:17:44,623 --> 05:17:45,623 After that we need the number of columns.\n 5972 05:17:45,623 --> 05:17:46,623 two in here is going to divide our screen\n 5973 05:17:46,623 --> 05:17:47,623 specific to different columns. And it's going\n 5974 05:17:47,623 --> 05:17:48,623 But before I run my application, I'm going\n 5975 05:17:48,623 --> 05:17:49,623 the contacts list item that XML file, I'm\n 5976 05:17:49,623 --> 05:17:50,623 of my relative layout to let's say wrap content.\n 5977 05:17:50,623 --> 05:17:51,623 it to match parent. I'm going to change that\n 5978 05:17:51,623 --> 05:17:52,623 You can see that the screen has been divided\n 5979 05:17:52,623 --> 05:17:53,623 we can see the contacts name in two different\n 5980 05:17:53,623 --> 05:17:54,623 this grid layout manager. Okay, now let's\n 5981 05:17:54,623 --> 05:17:55,623 each one of these items in our recycler view.\n 5982 05:17:55,623 --> 05:17:56,623 items, they are not going to do anything.\n 5983 05:17:56,623 --> 05:17:57,623 need to do that inside our contacts recycler\n 5984 05:17:57,623 --> 05:17:58,623 It was in our Java folder inside our project\n 5985 05:17:58,623 --> 05:17:59,623 you remember, I said that this unbind view\n 5986 05:17:59,623 --> 05:18:00,623 in your adapter class. And inside this method,\n 5987 05:18:00,623 --> 05:18:01,623 element that you want. Also, if you remember\n 5988 05:18:01,623 --> 05:18:02,623 an ID for this whole relative layout. If you\n 5989 05:18:02,623 --> 05:18:03,623 TextView but I think it's better To define\n 5990 05:18:03,623 --> 05:18:04,623 layout, because as you can see, we have this\n 5991 05:18:04,623 --> 05:18:05,623 layout are not going to be clickable if we\n 5992 05:18:05,623 --> 05:18:06,623 because I'm going to define the onClick listener\n 5993 05:18:06,623 --> 05:18:07,623 class, when I've created this view holder\n 5994 05:18:07,623 --> 05:18:08,623 to reference the relative layout as well.\n 5995 05:18:08,623 --> 05:18:09,623 name it parent. We also need to instantiate\n 5996 05:18:09,623 --> 05:18:10,623 can say parent is equal to item view dot find\n 5997 05:18:10,623 --> 05:18:11,623 parent. After defining this relative layout,\n 5998 05:18:11,623 --> 05:18:12,623 unbind view holder method. So for example,\n 5999 05:18:12,623 --> 05:18:13,623 is the name of this relative layout, dot,\n 6000 05:18:13,623 --> 05:18:14,623 that we have this option. Let's pass our interface\n 6001 05:18:14,623 --> 05:18:15,623 going to show some toast message. Let's say\n 6002 05:18:15,623 --> 05:18:16,623 make text method on our toast, we needed a\n 6003 05:18:16,623 --> 05:18:17,623 to any kind of context. Once again, we will\n 6004 05:18:17,623 --> 05:18:18,623 activities in Android, both inside this adapter\n 6005 05:18:18,623 --> 05:18:19,623 So we have to pass it inside the constructor.\n 6006 05:18:19,623 --> 05:18:20,623 as the member variable above in here, let's\n 6007 05:18:20,623 --> 05:18:21,623 And after that, I'm going to receive that\n 6008 05:18:21,623 --> 05:18:22,623 Let's name it context. Inside the constructor,\n 6009 05:18:22,623 --> 05:18:23,623 Whatever now that I have changed this constructor,\n 6010 05:18:23,623 --> 05:18:24,623 see some red warning. When we have instantiated\n 6011 05:18:24,623 --> 05:18:25,623 once again, because this time we are inside\n 6012 05:18:25,623 --> 05:18:26,623 this way inside our adapter, now we have a\n 6013 05:18:26,623 --> 05:18:27,623 we can pass that as the context. For the text,\n 6014 05:18:27,623 --> 05:18:28,623 So I can say contacts the ArrayList that we\n 6015 05:18:28,623 --> 05:18:29,623 to use this position as the index. 6016 05:18:29,623 --> 05:18:30,623 Let's say that get me. Also, if you have noticed\n 6017 05:18:30,623 --> 05:18:31,623 this onClick method, because we are inside\n 6018 05:18:31,623 --> 05:18:32,623 added to the declaration of this integer.\n 6019 05:18:32,623 --> 05:18:33,623 say selected. Let's quickly run the application.\n 6020 05:18:33,623 --> 05:18:34,623 onclicklistener on our relative layout. Let's\n 6021 05:18:34,623 --> 05:18:35,623 social arona social romance. It seems like\n 6022 05:18:35,623 --> 05:18:36,623 I think that's a good point to stop the video\n 6023 05:18:36,623 --> 05:18:37,623 URL and how to show that in our recycler view.\n 6024 05:18:37,623 --> 05:18:38,623 little bit long. So I'm going to talk about\n 6025 05:18:38,623 --> 05:18:39,623 also talk about using a combination of recycler\n 6026 05:18:39,623 --> 05:18:40,623 two will generate a really beautiful look\n 6027 05:18:40,623 --> 05:18:41,623 next video. In the previous video, we have\n 6028 05:18:41,623 --> 05:18:42,623 I mean, we have created a skeleton of our\n 6029 05:18:42,623 --> 05:18:43,623 If you take a look at your contact list item\n 6030 05:18:43,623 --> 05:18:44,623 in your recycler view is just a simple text\n 6031 05:18:44,623 --> 05:18:45,623 around this and we are going to see how much\n 6032 05:18:45,623 --> 05:18:46,623 recycler views. The first thing that I'm going\n 6033 05:18:46,623 --> 05:18:47,623 of this simple TextView and its parent which\n 6034 05:18:47,623 --> 05:18:48,623 contacts in a card view. For that first of\n 6035 05:18:48,623 --> 05:18:49,623 into our project. In previous videos when\n 6036 05:18:49,623 --> 05:18:50,623 we have added the material design library.\n 6037 05:18:50,623 --> 05:18:51,623 view instead of using the material design\n 6038 05:18:51,623 --> 05:18:52,623 Android cards Let's see where we can find\n 6039 05:18:52,623 --> 05:18:53,623 for card view dependencies, you will end up\n 6040 05:18:53,623 --> 05:18:54,623 x in your search because if you search for\n 6041 05:18:54,623 --> 05:18:55,623 Let's quickly take a look at that. In here\n 6042 05:18:55,623 --> 05:18:56,623 you are using comm dot Android dot Support\n 6043 05:18:56,623 --> 05:18:57,623 in our project right now, if you remember,\n 6044 05:18:57,623 --> 05:18:58,623 added the Android x artifacts. If you want\n 6045 05:18:58,623 --> 05:18:59,623 your gradle file. Let's quickly do that. So\n 6046 05:18:59,623 --> 05:19:00,623 in this build that Gradle module app, in these\n 6047 05:19:00,623 --> 05:19:01,623 using Android x. If for some reason you're\n 6048 05:19:01,623 --> 05:19:02,623 this support libraries version. But because\n 6049 05:19:02,623 --> 05:19:03,623 not going to be helpful for us. So make sure\n 6050 05:19:03,623 --> 05:19:04,623 And the first link from the official Android\n 6051 05:19:04,623 --> 05:19:05,623 link. Then in here, you can see the dependencies,\n 6052 05:19:05,623 --> 05:19:06,623 add the dependency from Android x packages.\n 6053 05:19:06,623 --> 05:19:07,623 it into our project. So once again, inside\n 6054 05:19:07,623 --> 05:19:08,623 these dependencies, we are going to add our\n 6055 05:19:08,623 --> 05:19:09,623 And let's sync our project. Now that I've\n 6056 05:19:09,623 --> 05:19:10,623 I can use it in my layout files, for example,\n 6057 05:19:10,623 --> 05:19:11,623 instead of this relative layout, I'm going\n 6058 05:19:11,623 --> 05:19:12,623 from Android x packages. If you remember in\n 6059 05:19:12,623 --> 05:19:13,623 be helpful in here. The first one is card\n 6060 05:19:13,623 --> 05:19:14,623 some 3d shapes to our card. For example, if\n 6061 05:19:14,623 --> 05:19:15,623 FTP. The next one is called corner radius.\n 6062 05:19:15,623 --> 05:19:16,623 to save five dB, I will change these numbers\n 6063 05:19:16,623 --> 05:19:17,623 card view, instead of this TextView, I'm going\n 6064 05:19:17,623 --> 05:19:18,623 relative layout is that because I'm going\n 6065 05:19:18,623 --> 05:19:19,623 to use some of the attributes like layout\n 6066 05:19:19,623 --> 05:19:20,623 that. And those attributes are available inside\n 6067 05:19:20,623 --> 05:19:21,623 in here, I'm going to create a relative layout.\n 6068 05:19:21,623 --> 05:19:22,623 parent. And I think that's enough for our\n 6069 05:19:22,623 --> 05:19:23,623 I'm going to move this TextView. First of\n 6070 05:19:23,623 --> 05:19:24,623 let's say center horizontal and let's pass\n 6071 05:19:24,623 --> 05:19:25,623 of this text. That's a text style. And let's\n 6072 05:19:25,623 --> 05:19:26,623 create another text view and I'm going to\n 6073 05:19:26,623 --> 05:19:27,623 this TextView. Let's change the contact name\n 6074 05:19:27,623 --> 05:19:28,623 to txt email. Let's also move this to below\n 6075 05:19:28,623 --> 05:19:29,623 txt name. Let's also change the styling here.\n 6076 05:19:29,623 --> 05:19:30,623 add some margin top margin top, let's say\n 6077 05:19:30,623 --> 05:19:31,623 horizontal attributes. Okay after these two\n 6078 05:19:31,623 --> 05:19:32,623 for that I'm going to create an image view.\n 6079 05:19:32,623 --> 05:19:33,623 of this image view because I want to have\n 6080 05:19:33,623 --> 05:19:34,623 numbers manually because my images are coming\n 6081 05:19:34,623 --> 05:19:35,623 about their size. For example in here I'm\n 6082 05:19:35,623 --> 05:19:36,623 fine. For the height as well. Once again 150\n 6083 05:19:36,623 --> 05:19:37,623 Let's just say image. I'm going to move these\n 6084 05:19:37,623 --> 05:19:38,623 below. And let's pass the email. Let's add\n 6085 05:19:38,623 --> 05:19:39,623 I'm also going to center this image via horizontally.\n 6086 05:19:39,623 --> 05:19:40,623 pass through. Let's also add a placeholder,\n 6087 05:19:40,623 --> 05:19:41,623 one of our images in our package. I think\n 6088 05:19:41,623 --> 05:19:42,623 Okay, I think that's enough for our current\n 6089 05:19:42,623 --> 05:19:43,623 let's just have a quick look of what our current\n 6090 05:19:43,623 --> 05:19:44,623 this coronary radius. For example, let's say\n 6091 05:19:44,623 --> 05:19:45,623 that, let's increase this card elevation.\n 6092 05:19:45,623 --> 05:19:46,623 you're satisfied. I'm almost done with this\n 6093 05:19:46,623 --> 05:19:47,623 reformat my code so that when I publish this\n 6094 05:19:47,623 --> 05:19:48,623 that, I'm going to go to this code tab in\nhere. 6095 05:19:48,623 --> 05:19:49,623 And down in here, I'm going to select this\n 6096 05:19:49,623 --> 05:19:50,623 been rearranged. Okay, now that I have changed\n 6097 05:19:50,623 --> 05:19:51,623 changes inside our recycler view adapter file\n 6098 05:19:51,623 --> 05:19:52,623 our view holder class, we need to address\n 6099 05:19:52,623 --> 05:19:53,623 item dot XML file. First of all, we have deleted\n 6100 05:19:53,623 --> 05:19:54,623 that with the current view. So in here, instead\n 6101 05:19:54,623 --> 05:19:55,623 current view. And let's also add our email\n 6102 05:19:55,623 --> 05:19:56,623 with this txt name. Let's say txt email. And\n 6103 05:19:56,623 --> 05:19:57,623 constructor. So let's say txt email is equal\n 6104 05:19:57,623 --> 05:19:58,623 txt email. We also need to add some quotes\n 6105 05:19:58,623 --> 05:19:59,623 example, we are going to show the contacts\n 6106 05:19:59,623 --> 05:20:00,623 holder dot txt email, dot set text. Let's\n 6107 05:20:00,623 --> 05:20:01,623 I'm going to pass position, let's say dot\n 6108 05:20:01,623 --> 05:20:02,623 I'm going to run the application. And I'm\n 6109 05:20:02,623 --> 05:20:03,623 fine. So let's run the application. You can\n 6110 05:20:03,623 --> 05:20:04,623 how much we have improved our layout. But\n 6111 05:20:04,623 --> 05:20:05,623 For example, we need to add some margin between\n 6112 05:20:05,623 --> 05:20:06,623 a margin top for this txt name. Let's quickly\n 6113 05:20:06,623 --> 05:20:07,623 list item dot XML file, for this parent card\n 6114 05:20:07,623 --> 05:20:08,623 top or instead of margin top, I'm just going\n 6115 05:20:08,623 --> 05:20:09,623 Beside that, let's also add a margin for this\n 6116 05:20:09,623 --> 05:20:10,623 a seven dp. Let's also add a margin was thought\n 6117 05:20:10,623 --> 05:20:11,623 I'm going to say margin start this one in\n 6118 05:20:11,623 --> 05:20:12,623 the application once again. You can see that\n 6119 05:20:12,623 --> 05:20:13,623 two attributes that we have added for our\n 6120 05:20:13,623 --> 05:20:14,623 all, we have added this corner radius, you\n 6121 05:20:14,623 --> 05:20:15,623 with a shadow behind our card view is for\n 6122 05:20:15,623 --> 05:20:16,623 the reason that we are seeing two columns\n 6123 05:20:16,623 --> 05:20:17,623 that we have passed to our recycler view.\n 6124 05:20:17,623 --> 05:20:18,623 change that, for example inside our main activity.\n 6125 05:20:18,623 --> 05:20:19,623 we can pass a linear layout manager. So in\n 6126 05:20:19,623 --> 05:20:20,623 And let's pass our context. Before I run this\n 6127 05:20:20,623 --> 05:20:21,623 centered my recycler view. Let's switch to\n 6128 05:20:21,623 --> 05:20:22,623 our recycler view. Let's say center horizontal.\n 6129 05:20:22,623 --> 05:20:23,623 change the width attribute in here to wrap\n 6130 05:20:23,623 --> 05:20:24,623 Right now you can see that we have only three\n 6131 05:20:24,623 --> 05:20:25,623 recycler view that's we could do that. You\n 6132 05:20:25,623 --> 05:20:26,623 screen. Our recycler view is a scroller but\n 6133 05:20:26,623 --> 05:20:27,623 Let's click on this link. cart view. And you\n 6134 05:20:27,623 --> 05:20:28,623 to be perfect. Okay, now let's work on this\n 6135 05:20:28,623 --> 05:20:29,623 images. For that we have multiple options,\n 6136 05:20:29,623 --> 05:20:30,623 called glide. Let's add that into our project.\n 6137 05:20:30,623 --> 05:20:31,623 for glide dependency, the first link from\n 6138 05:20:31,623 --> 05:20:32,623 library. Let's see what does it look like.\n 6139 05:20:32,623 --> 05:20:33,623 First of all, we need to add these two into\n 6140 05:20:33,623 --> 05:20:34,623 in our gradle file. Let's open our project\n 6141 05:20:34,623 --> 05:20:35,623 that Gradle project spawn in these repositories,\n 6142 05:20:35,623 --> 05:20:36,623 quickly add them. I'm going to copy this one\n 6143 05:20:36,623 --> 05:20:37,623 repositories for all projects. 6144 05:20:37,623 --> 05:20:38,623 Beside that, we need to add these two dependencies\n 6145 05:20:38,623 --> 05:20:39,623 design module app, we need to add the dependencies.\n 6146 05:20:39,623 --> 05:20:40,623 let's also talk about the SQLite. So glide\n 6147 05:20:40,623 --> 05:20:41,623 by Google so you can safely use it in your\n 6148 05:20:41,623 --> 05:20:42,623 in which one of them is to load images from\n 6149 05:20:42,623 --> 05:20:43,623 see other functionalities as well. But if\n 6150 05:20:43,623 --> 05:20:44,623 documentation in here, let's click on this\n 6151 05:20:44,623 --> 05:20:45,623 this page if you want. But we will talk about\n 6152 05:20:45,623 --> 05:20:46,623 switch back to our project. And it seems like\n 6153 05:20:46,623 --> 05:20:47,623 Let's close these two Gradle files. Also,\n 6154 05:20:47,623 --> 05:20:48,623 And let's go to our contacts recycler view\n 6155 05:20:48,623 --> 05:20:49,623 unbind view holder method, I'm going to show\n 6156 05:20:49,623 --> 05:20:50,623 I'm going to use the glide inside this method.\n 6157 05:20:50,623 --> 05:20:51,623 show images with glide library, you can say\n 6158 05:20:51,623 --> 05:20:52,623 capital G. And after that, you need to pass\n 6159 05:20:52,623 --> 05:20:53,623 with for the context in here, I'm going to\n 6160 05:20:53,623 --> 05:20:54,623 the context via the constructor of this class.\n 6161 05:20:54,623 --> 05:20:55,623 one in here. Now that we have our context,\n 6162 05:20:55,623 --> 05:20:56,623 that, I'm going to say that this image is\n 6163 05:20:56,623 --> 05:20:57,623 bitmap. After that, we need to pass the source\n 6164 05:20:57,623 --> 05:20:58,623 pass the image URL for our contact image,\n 6165 05:20:58,623 --> 05:20:59,623 image URL for that I'm going to say contacts\n 6166 05:20:59,623 --> 05:21:00,623 position as the index. That's a dot get image\n 6167 05:21:00,623 --> 05:21:01,623 view that we want to show our image inside\n 6168 05:21:01,623 --> 05:21:02,623 going to address my image view, which I can\n 6169 05:21:02,623 --> 05:21:03,623 of all, we need to add this image inside this\n 6170 05:21:03,623 --> 05:21:04,623 this view holder class, first of all, I'm\n 6171 05:21:04,623 --> 05:21:05,623 it image. And let's also instantiate it inside\n 6172 05:21:05,623 --> 05:21:06,623 to item view dot find view by ID r.id dot\n 6173 05:21:06,623 --> 05:21:07,623 First of all, we need to pass our context.\n 6174 05:21:07,623 --> 05:21:08,623 to be a bitmap file. After that, we need to\n 6175 05:21:08,623 --> 05:21:09,623 load method. And after that, we need to specify\n 6176 05:21:09,623 --> 05:21:10,623 image inside that this is going to work fine.\n 6177 05:21:10,623 --> 05:21:11,623 do one more thing. We are going to load different\n 6178 05:21:11,623 --> 05:21:12,623 to add a permission into our manifest file\n 6179 05:21:12,623 --> 05:21:13,623 talked about requesting permission. Let's\n 6180 05:21:13,623 --> 05:21:14,623 project main inside the app folder, inside\n 6181 05:21:14,623 --> 05:21:15,623 manifest dot XML file, we can add our permission\n 6182 05:21:15,623 --> 05:21:16,623 I can open a tag and the tag is going to be\n 6183 05:21:16,623 --> 05:21:17,623 need to assess To find the kind of permission,\n 6184 05:21:17,623 --> 05:21:18,623 can see this Android permission that internet.\n 6185 05:21:18,623 --> 05:21:19,623 regarding these permissions, we will talk\n 6186 05:21:19,623 --> 05:21:20,623 permissions, you need to create a UI logic\n 6187 05:21:20,623 --> 05:21:21,623 to your application. But this internet permission\n 6188 05:21:21,623 --> 05:21:22,623 your manifest file, the Android system is\n 6189 05:21:22,623 --> 05:21:23,623 we need to do in order to request for an internet\n 6190 05:21:23,623 --> 05:21:24,623 permissions. Let's just run our application.\n 6191 05:21:25,623 --> 05:21:26,623 You can see that we are seeing different images\n 6192 05:21:26,623 --> 05:21:27,623 this application after adding the permission\n 6193 05:21:27,623 --> 05:21:28,623 able to see the images. And that's because\n 6194 05:21:28,623 --> 05:21:29,623 you change your manifest file, you need to\n 6195 05:21:29,623 --> 05:21:30,623 again. So if you're not seeing different images,\n 6196 05:21:30,623 --> 05:21:31,623 install it once again. After that, you should\n 6197 05:21:31,623 --> 05:21:32,623 others you can see that the images are loading\n 6198 05:21:32,623 --> 05:21:33,623 can see that our recycler view our cart views\n 6199 05:21:33,623 --> 05:21:34,623 The combination of these three we'll create\n 6200 05:21:34,623 --> 05:21:35,623 to show a list of different items. And probably\n 6201 05:21:35,623 --> 05:21:36,623 of the functionalities of recycler view, you\n 6202 05:21:36,623 --> 05:21:37,623 our list item layout files however we want.\n 6203 05:21:37,623 --> 05:21:38,623 just to see our recycler view better. I'm\n 6204 05:21:38,623 --> 05:21:39,623 once again to a grid layout manager. And after\n 6205 05:21:39,623 --> 05:21:40,623 it back to grid layout manager and let's run\n 6206 05:21:40,623 --> 05:21:41,623 our RecyclerView seems perfect. Okay, I think\n 6207 05:21:41,623 --> 05:21:42,623 video, we are going to see how we can use\n 6208 05:21:42,623 --> 05:21:43,623 and external font that we don't have in Android\n 6209 05:21:43,623 --> 05:21:44,623 In this video, we are going to talk about\n 6210 05:21:44,623 --> 05:21:45,623 fonts to our TextView. Whether that font exists\n 6211 05:21:45,623 --> 05:21:46,623 add it externally. I believe this will be\n 6212 05:21:46,623 --> 05:21:47,623 we can add an external font into our project.\n 6213 05:21:47,623 --> 05:21:48,623 file and give an ID to this TextView. Let's\n 6214 05:21:48,623 --> 05:21:49,623 external font in your Resources folder, you\n 6215 05:21:49,623 --> 05:21:50,623 click on your resource folder. By selecting\n 6216 05:21:50,623 --> 05:21:51,623 that directory. We have done this when we\n 6217 05:21:51,623 --> 05:21:52,623 you just need to define the type of your resource,\n 6218 05:21:52,623 --> 05:21:53,623 all you need to do. Now you can see that you\n 6219 05:21:53,623 --> 05:21:54,623 external fonts into this folder. For example,\n 6220 05:21:54,623 --> 05:21:55,623 this font into my project, I need to do some\n 6221 05:21:55,623 --> 05:21:56,623 the name of this one. In order to add this\n 6222 05:21:56,623 --> 05:21:57,623 some rules. For example, you need to change\n 6223 05:21:57,623 --> 05:21:58,623 also you shouldn't use hyphens, instead of\n 6224 05:21:58,623 --> 05:21:59,623 I'm going to change the name a little bit.\n 6225 05:21:59,623 --> 05:22:00,623 you have changed the name, you can simply\n 6226 05:22:00,623 --> 05:22:01,623 you can paste it. The name is fine. Let's\n 6227 05:22:01,623 --> 05:22:02,623 have this Amsterdam, the TTF. If your font\n 6228 05:22:02,623 --> 05:22:03,623 clicking on your font. Okay, now that we have\n 6229 05:22:03,623 --> 05:22:04,623 it on our text view. Let's switch to our TextView\n 6230 05:22:04,623 --> 05:22:05,623 called font family. This one in here. And\n 6231 05:22:05,623 --> 05:22:06,623 font slash amster. No. Let's use to split\n 6232 05:22:06,623 --> 05:22:07,623 in the preview. You can see that right now\n 6233 05:22:07,623 --> 05:22:08,623 this will be changed when we run our application.\n 6234 05:22:08,623 --> 05:22:09,623 we can successfully change the font up artix\n 6235 05:22:09,623 --> 05:22:10,623 has been applied on our text the beside using\n 6236 05:22:10,623 --> 05:22:11,623 use some fonts called Google fonts. Let's\n 6237 05:22:11,623 --> 05:22:12,623 I'm going to switch to design view and search\n 6238 05:22:12,623 --> 05:22:13,623 that, we need to click on this text view.\n 6239 05:22:13,623 --> 05:22:14,623 that we have this attribute, and beside our\n 6240 05:22:14,623 --> 05:22:15,623 you have this drop down icon. If you click\n 6241 05:22:15,623 --> 05:22:16,623 some fonts that we can use. But besides all\n 6242 05:22:16,623 --> 05:22:17,623 And when we click on that, you can see that\n 6243 05:22:17,623 --> 05:22:18,623 Also, you can see the source in here it says\n 6244 05:22:18,623 --> 05:22:19,623 and you can safely use them in your applications.\n 6245 05:22:19,623 --> 05:22:20,623 somewhere. Okay, let's see what do we have\n 6246 05:22:20,623 --> 05:22:21,623 this calligraphy T or something like that,\n 6247 05:22:21,623 --> 05:22:22,623 we have two options, create downloadable font\n 6248 05:22:22,623 --> 05:22:23,623 means that you don't want to add the font\n 6249 05:22:23,623 --> 05:22:24,623 font every time that a user uses your application.\n 6250 05:22:24,623 --> 05:22:25,623 this option in here might not be that useful.\n 6251 05:22:25,623 --> 05:22:26,623 option which will add the font to my project.\n 6252 05:22:26,623 --> 05:22:27,623 apk file. Also, then in here, you can see\n 6253 05:22:27,623 --> 05:22:28,623 than one preview. And you can select between\n 6254 05:22:28,623 --> 05:22:29,623 regular. Also down in here, you can see the\n 6255 05:22:29,623 --> 05:22:30,623 your application. For the simple application.\n 6256 05:22:30,623 --> 05:22:31,623 going to be a commercial application. Okay,\n 6257 05:22:31,623 --> 05:22:32,623 OK, you can see that this calligraphy font\n 6258 05:22:32,623 --> 05:22:33,623 this will have a preview. So if I click on\n 6259 05:22:33,623 --> 05:22:34,623 Now if I run my application, I should see\n 6260 05:22:34,623 --> 05:22:35,623 You can see that the font has been applied\n 6261 05:22:35,623 --> 05:22:36,623 different styles for example, regular or normal,\n 6262 05:22:36,623 --> 05:22:37,623 see a font that has those styles. And let's\n 6263 05:22:37,623 --> 05:22:38,623 views. So once again, I'm going to click on\n 6264 05:22:38,623 --> 05:22:39,623 to click on this more fonts. The font that\n 6265 05:22:39,623 --> 05:22:40,623 two. If you click on that, you can see that\n 6266 05:22:40,623 --> 05:22:41,623 I'm going to add them one by one into my project.\n 6267 05:22:41,623 --> 05:22:42,623 to underline regular. And also I'm going to\n 6268 05:22:42,623 --> 05:22:43,623 a downloadable font. Let's press OK. And let's\n 6269 05:22:43,623 --> 05:22:44,623 You can see that now we have four different\n 6270 05:22:44,623 --> 05:22:45,623 on our text views, we can do the same as we\n 6271 05:22:45,623 --> 05:22:46,623 one font. For example, inside our text view.\n 6272 05:22:46,623 --> 05:22:47,623 the fonts manually by specifying the name\n 6273 05:22:47,623 --> 05:22:48,623 to the Android. For example, we can add a\n 6274 05:22:48,623 --> 05:22:49,623 size which can be it's fairly bold or normal.\n 6275 05:22:49,623 --> 05:22:50,623 if I change this lobster to Bold Italic to\n 6276 05:22:50,623 --> 05:22:51,623 that. If I run my application, I'm going to\n 6277 05:22:51,623 --> 05:22:52,623 Let's quickly run that. You can see that we\n 6278 05:22:52,623 --> 05:22:53,623 accurate because we have added the style manually.\n 6279 05:22:53,623 --> 05:22:54,623 to regular font. And if we want to use a specifically\n 6280 05:22:54,623 --> 05:22:55,623 font family for that. Let's quickly see how\n 6281 05:22:55,623 --> 05:22:56,623 resource folder, I can Right click, and by\n 6282 05:22:56,623 --> 05:22:57,623 a new font family. For the file name, I'm\n 6283 05:22:57,623 --> 05:22:58,623 case is lobster two. Let's create that. Inside\n 6284 05:22:58,623 --> 05:22:59,623 fonts, we need three attributes in here. First\n 6285 05:22:59,623 --> 05:23:00,623 For the first one, I'm going to pass the lobster\n 6286 05:23:00,623 --> 05:23:01,623 pass a style for this font, let's say font\n 6287 05:23:01,623 --> 05:23:02,623 styles Italia, and normal. In here, I'm going\n 6288 05:23:02,623 --> 05:23:03,623 bolder style, you need to pass that as a font\n 6289 05:23:03,623 --> 05:23:04,623 that we have this font fate attribute in which\n 6290 05:23:04,623 --> 05:23:05,623 fonts, these weights should be 400, I will\n 6291 05:23:05,623 --> 05:23:06,623 font weight that you need. But for now, let's\n 6292 05:23:06,623 --> 05:23:07,623 font. After that, I'm going to create three\n 6293 05:23:07,623 --> 05:23:08,623 the other three fonts, let's say font. Once\n 6294 05:23:08,623 --> 05:23:09,623 let's say lobster to retallick. For this style,\n 6295 05:23:09,623 --> 05:23:10,623 again, because this is not a bold font, we\n 6296 05:23:10,623 --> 05:23:11,623 Let's quickly add two more fonts for the bold\n 6297 05:23:11,623 --> 05:23:12,623 font I first normal as the font style. But\n 6298 05:23:12,623 --> 05:23:13,623 only difference between a bold and a regular\n 6299 05:23:13,623 --> 05:23:14,623 view half past 400 both for the bold ones\n 6300 05:23:14,623 --> 05:23:15,623 quickly see where we can find the proper font\n 6301 05:23:15,623 --> 05:23:16,623 developer, you can see this font weight from\n 6302 05:23:17,623 --> 05:23:18,623 And in here inside this companion properties,\n 6303 05:23:18,623 --> 05:23:19,623 fonts. For example, we have past 400 for the\n 6304 05:23:19,623 --> 05:23:20,623 For the bold ones, we also passed 700 I believe\n 6305 05:23:20,623 --> 05:23:21,623 If you pass for example 500. When the fonts\n 6306 05:23:21,623 --> 05:23:22,623 between these 407 100. So if you want you\n 6307 05:23:22,623 --> 05:23:23,623 back to Android Studio. Now that we have created\n 6308 05:23:23,623 --> 05:23:24,623 main dot XML file. But before that, you can\n 6309 05:23:24,623 --> 05:23:25,623 If you hover over one of them, it says that\n 6310 05:23:25,623 --> 05:23:26,623 26 and higher. So if your application is running\n 6311 05:23:26,623 --> 05:23:27,623 won't be applied. I've seen that some people\n 6312 05:23:27,623 --> 05:23:28,623 For example, you can see up in here, of course,\n 6313 05:23:28,623 --> 05:23:29,623 ALT plus enter, you can see that this new\n 6314 05:23:29,623 --> 05:23:30,623 talk about name spacing here. But basically\n 6315 05:23:30,623 --> 05:23:31,623 programming languages, you also have namespaces.\n 6316 05:23:31,623 --> 05:23:32,623 attribute is coming from. So some people are\n 6317 05:23:32,623 --> 05:23:33,623 you use this app namespace instead of Android,\n 6318 05:23:33,623 --> 05:23:34,623 levels as well. But honestly, I didn't see\n 6319 05:23:34,623 --> 05:23:35,623 one back to Android. And in my activity, main\n 6320 05:23:35,623 --> 05:23:36,623 So in here instead of passing lobster to regular\n 6321 05:23:36,623 --> 05:23:37,623 that we just created. And now this way we\n 6322 05:23:37,623 --> 05:23:38,623 system. So even though we are using this lobster\n 6323 05:23:38,623 --> 05:23:39,623 here, at the end, our font is going to be\n 6324 05:23:39,623 --> 05:23:40,623 our application and let's see if we can see\n 6325 05:23:40,623 --> 05:23:41,623 the bold font. Once again the difference in\n 6326 05:23:41,623 --> 05:23:42,623 this lobster to bold. But when we have passed\n 6327 05:23:42,623 --> 05:23:43,623 to bold, only the Android Studio increase\n 6328 05:23:43,623 --> 05:23:44,623 between different font styles. When the designer\n 6329 05:23:44,623 --> 05:23:45,623 a font family is much more accurate. Okay,\n 6330 05:23:45,623 --> 05:23:46,623 to show you how you can apply different fonts\n 6331 05:23:46,623 --> 05:23:47,623 in the design view, I'm going to add a button.\n 6332 05:23:47,623 --> 05:23:48,623 to change the font of this TextView. Let's\n 6333 05:23:48,623 --> 05:23:49,623 to let's say btn, change font. And also let's\n 6334 05:23:49,623 --> 05:23:50,623 text. I'm just going to say change in our\n 6335 05:23:51,623 --> 05:23:52,623 After that, let's set an onclicklistener.\n 6336 05:23:52,623 --> 05:23:53,623 new onclicklistener. Before this onClick listener,\n 6337 05:23:53,623 --> 05:23:54,623 that, I'm going to change the type face of\n 6338 05:23:54,623 --> 05:23:55,623 So above in here, let's say typeface, you\n 6339 05:23:55,623 --> 05:23:56,623 graphics package. Let's name it typeface is\n 6340 05:23:56,623 --> 05:23:57,623 to our font in our Resources folder. If I\n 6341 05:23:57,623 --> 05:23:58,623 that gets resources that get font. And if\n 6342 05:23:58,623 --> 05:23:59,623 say R dot font dot, let's say Amsterdam, you\n 6343 05:23:59,623 --> 05:24:00,623 in here. And the warning says that this method\n 6344 05:24:00,623 --> 05:24:01,623 You can overcome this problem by using resource\n 6345 05:24:01,623 --> 05:24:02,623 Let's quickly see that. So in here, I can\n 6346 05:24:02,623 --> 05:24:03,623 all, we need the context which I'm going to\n 6347 05:24:03,623 --> 05:24:04,623 font, let's say our dot font dot Amsterdam.\n 6348 05:24:04,623 --> 05:24:05,623 resource compat, which is a good option for\n 6349 05:24:05,623 --> 05:24:06,623 your typeface inside the onClick method, you\n 6350 05:24:06,623 --> 05:24:07,623 And you can pass your typeface. As simple\n 6351 05:24:07,623 --> 05:24:08,623 to let's run the application. And let's see\n 6352 05:24:08,623 --> 05:24:09,623 font is lobster too. If we click on this button,\n 6353 05:24:09,623 --> 05:24:10,623 it seems to be perfect. Okay, I think that's\n 6354 05:24:10,623 --> 05:24:11,623 for this section of the course. There are\n 6355 05:24:11,623 --> 05:24:12,623 when you're designing your layout files. For\n 6356 05:24:12,623 --> 05:24:13,623 have bottom navigation views, you have animations\n 6357 05:24:13,623 --> 05:24:14,623 I'm not going to talk about them in this section\n 6358 05:24:14,623 --> 05:24:15,623 concepts that we don't know anything about\n 6359 05:24:15,623 --> 05:24:16,623 a lot more tools for designing our layout\n 6360 05:24:16,623 --> 05:24:17,623 to have a quick challenge for this section\n 6361 05:24:17,623 --> 05:24:18,623 learned everything that we have talked so\n 6362 05:24:18,623 --> 05:24:19,623 at the end of the previous video, In this\n 6363 05:24:19,623 --> 05:24:20,623 The purpose of this challenge is to make sure\n 6364 05:24:20,623 --> 05:24:21,623 talked so far. And here is our challenge,\n 6365 05:24:21,623 --> 05:24:22,623 You can think of this layout file as a simple\n 6366 05:24:22,623 --> 05:24:23,623 the user's name, email, password, gender,\n 6367 05:24:23,623 --> 05:24:24,623 image view in here plus this button which\n 6368 05:24:24,623 --> 05:24:25,623 navigates to the user's gallery, or maybe\n 6369 05:24:25,623 --> 05:24:26,623 we don't know anything about that yet, this\n 6370 05:24:26,623 --> 05:24:27,623 purposes, these are not going to do anything.\n 6371 05:24:27,623 --> 05:24:28,623 after clicking on this image button. Beside\n 6372 05:24:28,623 --> 05:24:29,623 down below that you can see this checkbox\n 6373 05:24:29,623 --> 05:24:30,623 the register, we are going to show a snack\n 6374 05:24:30,623 --> 05:24:31,623 successfully. But if for example, the user\n 6375 05:24:31,623 --> 05:24:32,623 going to show a warning. Beside that we are\n 6376 05:24:32,623 --> 05:24:33,623 our license agreement. Okay, this is our challenge.\n 6377 05:24:33,623 --> 05:24:34,623 I'm sure that you can do it by yourself. But\n 6378 05:24:34,623 --> 05:24:35,623 lot of things that we have learned in In this\n 6379 05:24:35,623 --> 05:24:36,623 with a lot of UI elements beside that as you\n 6380 05:24:36,623 --> 05:24:37,623 Also, we are going to show a snack bars. And\n 6381 05:24:37,623 --> 05:24:38,623 initialize and work with our UI elements in\n 6382 05:24:38,623 --> 05:24:39,623 layout for that you want in order to design\n 6383 05:24:39,623 --> 05:24:40,623 in constraint layout. But if you want, you\n 6384 05:24:40,623 --> 05:24:41,623 Okay, pause the video in here and go solve\n 6385 05:24:41,623 --> 05:24:42,623 back to see my solution as well. Okay 6386 05:24:42,623 --> 05:24:43,623 I hope you solve the challenge, let's quickly\n 6387 05:24:43,623 --> 05:24:44,623 by creating a new project. For the name of\n 6388 05:24:44,623 --> 05:24:45,623 I'm going to save it API level 19. In this\n 6389 05:24:45,623 --> 05:24:46,623 let's start working on our layout file. But\n 6390 05:24:46,623 --> 05:24:47,623 extra files and panes. As I said, I'm going\n 6391 05:24:47,623 --> 05:24:48,623 want, you can work with linear layout or relative\n 6392 05:24:48,623 --> 05:24:49,623 TextView. And let's drag all of our items.\n 6393 05:24:49,623 --> 05:24:50,623 image profile. For the sample data, I'm going\n 6394 05:24:50,623 --> 05:24:51,623 a button. Beside that we are going to need\n 6395 05:24:51,623 --> 05:24:52,623 in a minute. But before that, let's quickly\n 6396 05:24:52,623 --> 05:24:53,623 edit texts in here, the first two are going\n 6397 05:24:53,623 --> 05:24:54,623 going to be password. The first two are for\n 6398 05:24:54,623 --> 05:24:55,623 passwords in here. The difference between\n 6399 05:24:55,623 --> 05:24:56,623 is that when you type something inside the\n 6400 05:24:56,623 --> 05:24:57,623 itself, but you will see some dots. Also beside\n 6401 05:24:57,623 --> 05:24:58,623 After that we need a radio group. Let's quickly\n 6402 05:24:58,623 --> 05:24:59,623 radio buttons. Also, I'm not sure that if\n 6403 05:24:59,623 --> 05:25:00,623 in your radio group in the design view. Previously,\n 6404 05:25:00,623 --> 05:25:01,623 a radio group in the TextView. But here is\n 6405 05:25:01,623 --> 05:25:02,623 you can use these components three, for example,\n 6406 05:25:02,623 --> 05:25:03,623 radio group. Let's add two more. Let's also\n 6407 05:25:03,623 --> 05:25:04,623 group. Let's search for the orientation in\n 6408 05:25:04,623 --> 05:25:05,623 to change it to horizontal. Beside that we\n 6409 05:25:05,623 --> 05:25:06,623 we need a spinner in here for selecting one\n 6410 05:25:06,623 --> 05:25:07,623 Let's quickly change the viets of this spinner\n 6411 05:25:07,623 --> 05:25:08,623 is not match parent in here, it's just some\n 6412 05:25:08,623 --> 05:25:09,623 Also I think it's better to put it above in\n 6413 05:25:09,623 --> 05:25:10,623 everything. If you remember we had the button.\n 6414 05:25:10,623 --> 05:25:11,623 our button register. Beside that we need a\n 6415 05:25:11,623 --> 05:25:12,623 And also we needed a checkbox. Let's search\n 6416 05:25:12,623 --> 05:25:13,623 value of this checkbox to true let's search\n 6417 05:25:13,623 --> 05:25:14,623 Also, I'm going to change the checked value\n 6418 05:25:14,623 --> 05:25:15,623 let's quickly change the idea of our UI elements\n 6419 05:25:15,623 --> 05:25:16,623 I'm going to fast forward the process of giving\n 6420 05:25:16,623 --> 05:25:17,623 UI element and you can change the attributes\n 6421 05:25:17,623 --> 05:25:18,623 Just a quick review, let's quickly see the\n 6422 05:25:18,623 --> 05:25:19,623 going to use them in our Java file. This one\n 6423 05:25:19,623 --> 05:25:20,623 edit text name edit text email, edit text\n 6424 05:25:20,623 --> 05:25:21,623 this morning here is our agenda for our radio\n 6425 05:25:21,623 --> 05:25:22,623 be male or be female and or the other. This\n 6426 05:25:22,623 --> 05:25:23,623 is called a screener country and this button\n 6427 05:25:23,623 --> 05:25:24,623 called a txt agreement. And this checkbox\n 6428 05:25:24,623 --> 05:25:25,623 to need four more text views. If you remember\n 6429 05:25:25,623 --> 05:25:26,623 button, we are going to make sure that we\n 6430 05:25:26,623 --> 05:25:27,623 if for some reason the user don't enter anything\n 6431 05:25:27,623 --> 05:25:28,623 warnings and we are going to use text views\n 6432 05:25:28,623 --> 05:25:29,623 more text views. I'm going to add Warning\n 6433 05:25:29,623 --> 05:25:30,623 Let's quickly give some ID to these. For example,\n 6434 05:25:31,623 --> 05:25:32,623 the rest of them. This one is txt one email.\n 6435 05:25:32,623 --> 05:25:33,623 txt var is repeat. Okay, now that we have\n 6436 05:25:33,623 --> 05:25:34,623 quickly change the initial values. For example,\n 6437 05:25:34,623 --> 05:25:35,623 anything, but for this edit text, I'm going\n 6438 05:25:35,623 --> 05:25:36,623 hint. Let's search for the hint. That's just\n 6439 05:25:36,623 --> 05:25:37,623 options, which can be annoying by pressing\n 6440 05:25:37,623 --> 05:25:38,623 rid of that suggestion, let's do the same\n 6441 05:25:38,623 --> 05:25:39,623 this TextView, I'm going to change its value\n 6442 05:25:39,623 --> 05:25:40,623 let's change the first one to make the next\n 6443 05:25:40,623 --> 05:25:41,623 name either this TextView in here, let's change\n 6444 05:25:41,623 --> 05:25:42,623 buttons text to peak image. And this font\n 6445 05:25:42,623 --> 05:25:43,623 Beside that, we need to change the value of\n 6446 05:25:43,623 --> 05:25:44,623 later on when we created our constraints.\n 6447 05:25:44,623 --> 05:25:45,623 Also, I'm going to change the color of these\n 6448 05:25:45,623 --> 05:25:46,623 that. Let's search for color. And let's change\n 6449 05:25:46,623 --> 05:25:47,623 be fine. Now let's start constraining our\n 6450 05:25:47,623 --> 05:25:48,623 I'm going to constrain it to the left of my\n 6451 05:25:48,623 --> 05:25:49,623 of course, I need some merging. I will add\n 6452 05:25:49,623 --> 05:25:50,623 this image view to the left of my button,\n 6453 05:25:50,623 --> 05:25:51,623 of my screen. Beside that I'm going to constrain\n 6454 05:25:51,623 --> 05:25:52,623 Similar thing for the top of my image view.\n 6455 05:25:52,623 --> 05:25:53,623 view. For example, margin top, let's say 32,\n 6456 05:25:53,623 --> 05:25:54,623 But as you can see, when I move this image\n 6457 05:25:54,623 --> 05:25:55,623 I'm going to delete this right constraint.\n 6458 05:25:55,623 --> 05:25:56,623 this button to the right of my image view.\n 6459 05:25:56,623 --> 05:25:57,623 right of our screen. And now we can move it.\n 6460 05:25:57,623 --> 05:25:58,623 First of all, I'm going to add a horizontal\n 6461 05:25:58,623 --> 05:25:59,623 and let's go to this helpers. And let's add\n 6462 05:25:59,623 --> 05:26:00,623 to somewhere about here. I think it's fine.\n 6463 05:26:00,623 --> 05:26:01,623 Let's quickly add that helpers add vertical\n 6464 05:26:01,623 --> 05:26:02,623 Now let's constraint our edit texts. For example,\n 6465 05:26:02,623 --> 05:26:03,623 this TextView to this guideline as well. Also,\n 6466 05:26:03,623 --> 05:26:04,623 of this edit text to the bottom of this TextView.\n 6467 05:26:04,623 --> 05:26:05,623 each other. What you can do is that by pressing\n 6468 05:26:05,623 --> 05:26:06,623 them. And by right clicking, you can use this\n 6469 05:26:06,623 --> 05:26:07,623 let's say Edit Text name, let's say top to\n 6470 05:26:07,623 --> 05:26:08,623 see that now we have a constraint. Beside\n 6471 05:26:08,623 --> 05:26:09,623 top of this TextView to our horizontal guideline.\n 6472 05:26:09,623 --> 05:26:10,623 And let's right click constraint txt warning\n 6473 05:26:10,623 --> 05:26:11,623 I'm going to remove the margin here you can\n 6474 05:26:11,623 --> 05:26:12,623 that to zero, I believe is fine. Let's do\n 6475 05:26:12,623 --> 05:26:13,623 text views. For these three remaining text\n 6476 05:26:13,623 --> 05:26:14,623 top edit text but I'm also going to add a\n 6477 05:26:14,623 --> 05:26:15,623 email top to the bottom of our edit text name.\n 6478 05:26:15,623 --> 05:26:16,623 I'm going to save it 16 Okay, let's do the\n 6479 05:26:17,623 --> 05:26:18,623 We can see that everything looks better. Now.\n 6480 05:26:18,623 --> 05:26:19,623 you can always go to this icon in here and\n 6481 05:26:19,623 --> 05:26:20,623 you can work with blueprint view, which you\n 6482 05:26:20,623 --> 05:26:21,623 Let's quickly see that you can work with this\n 6483 05:26:21,623 --> 05:26:22,623 save it to design view. Okay, let's add a\n 6484 05:26:22,623 --> 05:26:23,623 all, I'm going to construct it to the top\n 6485 05:26:23,623 --> 05:26:24,623 top to, let's say, bottom of our edit text,\n 6486 05:26:24,623 --> 05:26:25,623 24 would be fine, it seems too much, let's\n 6487 05:26:25,623 --> 05:26:26,623 of our screen, let's add a margin in here\n 6488 05:26:26,623 --> 05:26:27,623 the radio group from this component tree.\n 6489 05:26:27,623 --> 05:26:28,623 it to this guideline. Also, I'm going to add\n 6490 05:26:28,623 --> 05:26:29,623 to the bottom of this gender TextView. Once\n 6491 05:26:29,623 --> 05:26:30,623 let's say constraint. It seems like I didn't\n 6492 05:26:30,623 --> 05:26:31,623 this component three if you want. Let's select\n 6493 05:26:31,623 --> 05:26:32,623 let's say radio group gender, top to bottom\n 6494 05:26:32,623 --> 05:26:33,623 let's also add a margin, I think 16 would\n 6495 05:26:33,623 --> 05:26:34,623 do the same thing. For the left margin, let's\n 6496 05:26:34,623 --> 05:26:35,623 constraint. txt country talk to the bottom\n 6497 05:26:35,623 --> 05:26:36,623 months again, for the spinner, I'm going to\n 6498 05:26:36,623 --> 05:26:37,623 And also its bottom and top to the bottom\n 6499 05:26:37,623 --> 05:26:38,623 course, we need a margin left. Let's quickly\n 6500 05:26:38,623 --> 05:26:39,623 to constraint it to the three edges of my\n 6501 05:26:39,623 --> 05:26:40,623 add 32. For example, I think that's fine.\n 6502 05:26:40,623 --> 05:26:41,623 guideline in here. Let's quickly add that\n 6503 05:26:41,623 --> 05:26:42,623 move this guideline, let's move it to somewhere\n 6504 05:26:42,623 --> 05:26:43,623 to this one in here. For the top, I'm going\n 6505 05:26:43,623 --> 05:26:44,623 Let's also constraint this checkbox. I'm also\n 6506 05:26:44,623 --> 05:26:45,623 to the bottom of our TextView. Let's add another\n 6507 05:26:45,623 --> 05:26:46,623 a horizontal guideline. And let's move it\n 6508 05:26:46,623 --> 05:26:47,623 add a constraint from the bottom of this checkbox\n 6509 05:26:47,623 --> 05:26:48,623 like we don't have a proper constraint in\n 6510 05:26:48,623 --> 05:26:49,623 constraint, we can delete the constraint by\n 6511 05:26:49,623 --> 05:26:50,623 to delete key. Let's also add a constraint\n 6512 05:26:50,623 --> 05:26:51,623 horizontal guideline. Also, I'm going to move\n 6513 05:26:51,623 --> 05:26:52,623 Now, let's also change the text of this TextView.\n 6514 05:26:52,623 --> 05:26:53,623 four warning text to gone. First of all, let's\n 6515 05:26:53,623 --> 05:26:54,623 see that as soon as I typed the TextView in\n 6516 05:26:54,623 --> 05:26:55,623 other layout files. And also it doesn't fit\n 6517 05:26:55,623 --> 05:26:56,623 can click on this to arrow in here. And you\n 6518 05:26:56,623 --> 05:26:57,623 what we also need a margin. Let's quickly\n 6519 05:26:57,623 --> 05:26:58,623 that seems with it. Also, I think it's better\n 6520 05:26:58,623 --> 05:26:59,623 Let's click on that. And let's move it above.\n 6521 05:26:59,623 --> 05:27:00,623 the visibility of this for one new text views\n 6522 05:27:00,623 --> 05:27:01,623 let's change it to gone. Similarly for the\n 6523 05:27:01,623 --> 05:27:02,623 that, you can see that we have two small margins,\n 6524 05:27:02,623 --> 05:27:03,623 say eight in here. Similarly for the next\n 6525 05:27:03,623 --> 05:27:04,623 that's about the size of our layout file.\n 6526 05:27:04,623 --> 05:27:05,623 Let's quickly add them in our strings values\n 6527 05:27:05,623 --> 05:27:06,623 strings. I'm going to add an array string 6528 05:27:06,623 --> 05:27:07,623 let's say array. Let's name it countries.\n 6529 05:27:07,623 --> 05:27:08,623 main dot XML file, we can pass this as the\n 6530 05:27:08,623 --> 05:27:09,623 and let's address our country's array. Okay,\n 6531 05:27:09,623 --> 05:27:10,623 image view, we also need a source. Let's search\n 6532 05:27:10,623 --> 05:27:11,623 see source in here, let's switch to text view\n 6533 05:27:11,623 --> 05:27:12,623 Let's say source. And let's pass this mid\n 6534 05:27:12,623 --> 05:27:13,623 testing the application, let's quickly add\n 6535 05:27:13,623 --> 05:27:14,623 to go to material.io. Let's go to this Developer\n 6536 05:27:14,623 --> 05:27:15,623 Android in the documentation getting started.\n 6537 05:27:15,623 --> 05:27:16,623 add that in our project Gradle script build\n 6538 05:27:16,623 --> 05:27:17,623 the dependencies. Let's add that we also need\n 6539 05:27:17,623 --> 05:27:18,623 see in the warning, the latest version is\n 6540 05:27:18,623 --> 05:27:19,623 let's go to our styles and change the theme\n 6541 05:27:19,623 --> 05:27:20,623 theme in here. And I'm going to use team dot\n 6542 05:27:20,623 --> 05:27:21,623 We have used these previously in previous\n 6543 05:27:21,623 --> 05:27:22,623 main file, you can see that the state of our\n 6544 05:27:22,623 --> 05:27:23,623 I'm going to run the application on pixel\n 6545 05:27:23,623 --> 05:27:24,623 relatively good job, we just need to increase\n 6546 05:27:24,623 --> 05:27:25,623 to change the width and height of this image\n 6547 05:27:25,623 --> 05:27:26,623 say 130 dP, I think that would be fine. Let's\n 6548 05:27:26,623 --> 05:27:27,623 you can also decrease the size of this TextView\n 6549 05:27:27,623 --> 05:27:28,623 design might be different than mine. It's\n 6550 05:27:28,623 --> 05:27:29,623 a designer, but we just wanted to practice\n 6551 05:27:29,623 --> 05:27:30,623 that's enough for this video. In the next\n 6552 05:27:30,623 --> 05:27:31,623 file and we are going to work on the logic\n 6553 05:27:31,623 --> 05:27:32,623 In the previous video, we have created this\n 6554 05:27:32,623 --> 05:27:33,623 video, we are going to work on the Java file\n 6555 05:27:33,623 --> 05:27:34,623 that, let's switch to our main activity dot\n 6556 05:27:34,623 --> 05:27:35,623 First of all in here, I'm going to initialize\n 6557 05:27:35,623 --> 05:27:36,623 quickly add a lock, I believe it will be useful,\n 6558 05:27:36,623 --> 05:27:37,623 text, I'm going to fast forward the process\n 6559 05:27:37,623 --> 05:27:38,623 you can see that it's very boring. I'm also\n 6560 05:27:38,623 --> 05:27:39,623 in here, let's say private constraint layout.\n 6561 05:27:39,623 --> 05:27:40,623 on, we will use this constraint layout to\n 6562 05:27:40,623 --> 05:27:41,623 to my constraint layout. So for that, let's\n 6563 05:27:41,623 --> 05:27:42,623 our split view, in the parent constraint layout,\n 6564 05:27:42,623 --> 05:27:43,623 I'm going to say parent. Okay, now let's initialize\n 6565 05:27:43,623 --> 05:27:44,623 that inside another method. Let's name that\n 6566 05:27:44,623 --> 05:27:45,623 let's create that method down in here, private\n 6567 05:27:45,623 --> 05:27:46,623 a look. Let's get started. Let's minimize\n 6568 05:27:46,623 --> 05:27:47,623 again, I'm going to fast forward the process\n 6569 05:27:47,623 --> 05:27:48,623 I have a typo in here. But I have set an ID\n 6570 05:27:48,623 --> 05:27:49,623 that in our layout file. If I click on this\n 6571 05:27:49,623 --> 05:27:50,623 of sorry for that, I also need to change it\n 6572 05:27:50,623 --> 05:27:51,623 all of our views, I'm going to set an onclicklistener.\n 6573 05:27:51,623 --> 05:27:52,623 about this one in here. So after this method,\n 6574 05:27:53,623 --> 05:27:54,623 Let's just show a toast message. We haven't\n 6575 05:27:54,623 --> 05:27:55,623 a gallery, or for that matter to take a picture\n 6576 05:27:55,623 --> 05:27:56,623 just going to show this first message. After\n 6577 05:27:56,623 --> 05:27:57,623 btn finish or btn register. I believe I named\n 6578 05:27:57,623 --> 05:27:58,623 I'm going to do the job inside another method,\n 6579 05:27:58,623 --> 05:27:59,623 method down in here. Let's say private void\n 6580 05:27:59,623 --> 05:28:00,623 a look. Let's say start in here. First of\n 6581 05:28:00,623 --> 05:28:01,623 entered all of the data for that, I'm going\n 6582 05:28:01,623 --> 05:28:02,623 I will create that in a minute. But let's\n 6583 05:28:02,623 --> 05:28:03,623 we are going to continue. Let's quickly create\n 6584 05:28:03,623 --> 05:28:04,623 we are going to do inside this method. Private\n 6585 05:28:04,623 --> 05:28:05,623 let's say private, Boolean, validate data.\n 6586 05:28:05,623 --> 05:28:06,623 edit txt name dot get text.to string if it's\n 6587 05:28:06,623 --> 05:28:07,623 are going to show the warning text. So let's\n 6588 05:28:07,623 --> 05:28:08,623 visibility. Let's fast be Zeebo. I believe\n 6589 05:28:08,623 --> 05:28:09,623 after that we are going to return false it\n 6590 05:28:09,623 --> 05:28:10,623 we shouldn't continue our code. In this method\n 6591 05:28:10,623 --> 05:28:11,623 more if statement for the other three edit\n 6592 05:28:11,623 --> 05:28:12,623 string is equal to an empty string. txt warning\n 6593 05:28:12,623 --> 05:28:13,623 also going to return false in here as well.\n 6594 05:28:13,623 --> 05:28:14,623 false, we are going to change the text of\n 6595 05:28:14,623 --> 05:28:15,623 in the layout file, we didn't change the text\n 6596 05:28:15,623 --> 05:28:16,623 warning name, for example, dot txt, let's\n 6597 05:28:16,623 --> 05:28:17,623 other three cases. And after all of these\n 6598 05:28:17,623 --> 05:28:18,623 we reach to this point we are going to return\n 6599 05:28:18,623 --> 05:28:19,623 of the data. So inside this validate data\n 6600 05:28:19,623 --> 05:28:20,623 all of the blanks after that inside this init\n 6601 05:28:20,623 --> 05:28:21,623 we are going to check that if the user agrees\n 6602 05:28:21,623 --> 05:28:22,623 agreement check that is checked this option\n 6603 05:28:22,623 --> 05:28:23,623 to continue. But in the else case, we are\n 6604 05:28:23,623 --> 05:28:24,623 say you need to agree to the license agreement.\n 6605 05:28:24,623 --> 05:28:25,623 the user enters all of the data and also agree\n 6606 05:28:25,623 --> 05:28:26,623 show a snack bar. Let's do that in another\n 6607 05:28:26,623 --> 05:28:27,623 create that method down here. Private void\n 6608 05:28:27,623 --> 05:28:28,623 then in here inside this method, first of\n 6609 05:28:28,623 --> 05:28:29,623 of our warning texts, because those warnings\n 6610 05:28:29,623 --> 05:28:30,623 name that says visibility, let's say gone\n 6611 05:28:30,623 --> 05:28:31,623 other three remaining burning texts. After\n 6612 05:28:31,623 --> 05:28:32,623 remember, we can do something like this, we\n 6613 05:28:32,623 --> 05:28:33,623 we need to pass our constraint layout, which\n 6614 05:28:33,623 --> 05:28:34,623 need to text in here right now I'm going to\n 6615 05:28:34,623 --> 05:28:35,623 to say user registered. But later on, I will\n 6616 05:28:35,623 --> 05:28:36,623 the details of the newly registered user.\n 6617 05:28:36,623 --> 05:28:37,623 we need the constant for the length of our\n 6618 05:28:37,623 --> 05:28:38,623 length indefinite. Let's also define an action\n 6619 05:28:38,623 --> 05:28:39,623 that's an action. For the text, I'm just going\nto say dismissed. 6620 05:28:39,623 --> 05:28:40,623 Let's also create an onclicklistener, let's\n 6621 05:28:40,623 --> 05:28:41,623 I'm not going to do inside this onClick method.\n 6622 05:28:41,623 --> 05:28:42,623 finish creating our snack bar. But before\n 6623 05:28:42,623 --> 05:28:43,623 show. Let's run the application. And let's\n 6624 05:28:43,623 --> 05:28:44,623 First of all, let's click on the speak Image\n 6625 05:28:44,623 --> 05:28:45,623 can see that you have to be talked about.\n 6626 05:28:45,623 --> 05:28:46,623 a new user. Let's say Mesa, let's add an email.\n 6627 05:28:46,623 --> 05:28:47,623 passport. We also need to check that if these\n 6628 05:28:47,623 --> 05:28:48,623 do that after the testing of this phase of\n 6629 05:28:48,623 --> 05:28:49,623 I'm going to uncheck this alone. License Agreement\n 6630 05:28:49,623 --> 05:28:50,623 that you need to agree to the license agreement.\n 6631 05:28:50,623 --> 05:28:51,623 this time we should see this network user\n 6632 05:28:51,623 --> 05:28:52,623 working fine. If we press dismiss, the snack\n 6633 05:28:52,623 --> 05:28:53,623 this email in here. And let's see if we get\n 6634 05:28:53,623 --> 05:28:54,623 button, you can see that insert your email,\n 6635 05:28:54,623 --> 05:28:55,623 we enter an email in here, for example, may\n 6636 05:28:55,623 --> 05:28:56,623 button, we should see that the email warning\n 6637 05:28:56,623 --> 05:28:57,623 the application. First of all, I'm going to\n 6638 05:28:57,623 --> 05:28:58,623 I'm also going to empty all of these for any\n 6639 05:28:58,623 --> 05:28:59,623 so that we can add a new user. Also, I'm going\n 6640 05:28:59,623 --> 05:29:00,623 details of our newly registered user. Let's\n 6641 05:29:00,623 --> 05:29:01,623 validate data method, I'm going to add another\n 6642 05:29:01,623 --> 05:29:02,623 this font dot get text to string. If that's\n 6643 05:29:02,623 --> 05:29:03,623 get text to string. If that's the case, or\n 6644 05:29:03,623 --> 05:29:04,623 not the case. First of all, we are going to\n 6645 05:29:04,623 --> 05:29:05,623 password repeat. And after that, we are going\n 6646 05:29:05,623 --> 05:29:06,623 password repeat dot set visibility, let's\n 6647 05:29:06,623 --> 05:29:07,623 the text I'm going to say txt warning, repeat\n 6648 05:29:07,623 --> 05:29:08,623 match. Up. After that I'm going to return\n 6649 05:29:08,623 --> 05:29:09,623 data successfully, let's go to this onClick\n 6650 05:29:09,623 --> 05:29:10,623 text. I'm going to say Edit Text email or\n 6651 05:29:10,623 --> 05:29:11,623 an empty string. Similarly for the other three\n 6652 05:29:11,623 --> 05:29:12,623 is that I'm going to change the text of this\n 6653 05:29:12,623 --> 05:29:13,623 that text above in here, inside this short\n 6654 05:29:13,623 --> 05:29:14,623 to get the user's data. For example, let's\n 6655 05:29:14,623 --> 05:29:15,623 dot get text.to string. Similarly, for the\n 6656 05:29:15,623 --> 05:29:16,623 equal to edit text email dot get text.to string,\n 6657 05:29:16,623 --> 05:29:17,623 country, let's say a string country is equal\n 6658 05:29:17,623 --> 05:29:18,623 string for getting the user's gender, I'm\n 6659 05:29:18,623 --> 05:29:19,623 that I'm going to create a string, let's say\n 6660 05:29:19,623 --> 05:29:20,623 After that, let's create a switch statement\n 6661 05:29:20,623 --> 05:29:21,623 get checked radio button ID. Let's say in\n 6662 05:29:21,623 --> 05:29:22,623 are going to change the value of this gender\n 6663 05:29:22,623 --> 05:29:23,623 Sorry about that. Let's also add a break in\n 6664 05:29:23,623 --> 05:29:24,623 say gender is equal to female. This default\n 6665 05:29:24,623 --> 05:29:25,623 purposes, if something goes wrong, I'm assigning\n 6666 05:29:25,623 --> 05:29:26,623 switch statement, we have all of the data\n 6667 05:29:26,623 --> 05:29:27,623 that we want to show inside the snack bar.\n 6668 05:29:28,623 --> 05:29:29,623 and let's create our text. First of all, I'm\n 6669 05:29:29,623 --> 05:29:30,623 or we got from the Edit Text name. After that,\n 6670 05:29:30,623 --> 05:29:31,623 go to the next line, let's say email, plus\n 6671 05:29:31,623 --> 05:29:32,623 also show the gender and country, let's say\n 6672 05:29:32,623 --> 05:29:33,623 n and also let's show the country. Now that\n 6673 05:29:33,623 --> 05:29:34,623 in our snack bar. So this time, instead of\n 6674 05:29:34,623 --> 05:29:35,623 Let's run the application once again. And\n 6675 05:29:35,623 --> 05:29:36,623 successfully. Let's test the different cases.\n 6676 05:29:36,623 --> 05:29:37,623 warning if we enter different passwords in\n 6677 05:29:37,623 --> 05:29:38,623 I'm going to enter 123456 but in the reenter\n 6678 05:29:38,623 --> 05:29:39,623 If we click on this register button, we should\n 6679 05:29:39,623 --> 05:29:40,623 Okay, let's add six in here. Now they do match,\n 6680 05:29:40,623 --> 05:29:41,623 Switzerland. And also let's change the gender\n 6681 05:29:41,623 --> 05:29:42,623 reduce there any user. In here you can see\n 6682 05:29:42,623 --> 05:29:43,623 have created. But we are not seeing all of\n 6683 05:29:43,623 --> 05:29:44,623 If you want to change the maximum line attribute\n 6684 05:29:44,623 --> 05:29:45,623 of all, you need to get the instance of your\n 6685 05:29:45,623 --> 05:29:46,623 text view of your snack bar. And after that,\n 6686 05:29:46,623 --> 05:29:47,623 text view. This way, you can override the\n 6687 05:29:47,623 --> 05:29:48,623 your snack bar. But that seems like a lot\n 6688 05:29:48,623 --> 05:29:49,623 here. We will do that later on in the course\n 6689 05:29:49,623 --> 05:29:50,623 in here, if you want to make sure that you\n 6690 05:29:50,623 --> 05:29:51,623 you can simply log it. For example, in here,\n 6691 05:29:51,623 --> 05:29:52,623 let's say a snack bar text. Let's pass our\n 6692 05:29:52,623 --> 05:29:53,623 and test this, I'm going to click on this\n 6693 05:29:53,623 --> 05:29:54,623 the logic so that we clear all of our edit\n 6694 05:29:54,623 --> 05:29:55,623 are now ready to register a new user. Let's\n 6695 05:29:55,623 --> 05:29:56,623 test this snack text. For that I'm going to\n 6696 05:29:56,623 --> 05:29:57,623 here. And let's click on this register. You\n 6697 05:29:57,623 --> 05:29:58,623 may be some@gmail.com gender male country,\n 6698 05:29:58,623 --> 05:29:59,623 text successfully. Okay, I think that's enough\n 6699 05:29:59,623 --> 05:30:00,623 the challenge. In the next section of the\n 6700 05:30:00,623 --> 05:30:01,623 four of our applications. Now we know about\n 6701 05:30:01,623 --> 05:30:02,623 in the next section of the course we are going\n 6702 05:30:02,623 --> 05:30:03,623 our first real world application. Beside practicing\n 6703 05:30:03,623 --> 05:30:04,623 are also going to learn a lot of new stuff\n 6704 05:30:04,623 --> 05:30:05,623 of the course. And as always see you in the\n 6705 05:30:05,623 --> 05:30:06,623 having fun. Before we start creating our sample\n 6706 05:30:06,623 --> 05:30:07,623 there is an extended version of this course\n 6707 05:30:07,623 --> 05:30:08,623 course you will have lifetime access to more\n 6708 05:30:08,623 --> 05:30:09,623 questions directly from me and I will come\n 6709 05:30:09,623 --> 05:30:10,623 to all of the source codes that I wrote in\n 6710 05:30:10,623 --> 05:30:11,623 all of the new videos that I upload, just\n 6711 05:30:11,623 --> 05:30:12,623 the course. And don't forget to use Free Code\n 6712 05:30:12,623 --> 05:30:13,623 If you want to get serious in Android app\n 6713 05:30:13,623 --> 05:30:14,623 almost a necessity. Okay, everyone, I just\n 6714 05:30:14,623 --> 05:30:15,623 version of this course that you can take without\n 6715 05:30:15,623 --> 05:30:16,623 application. Have fun learning. 6716 05:30:16,623 --> 05:30:17,623 Hello, everyone, and welcome back. In this\n 6717 05:30:17,623 --> 05:30:18,623 the first application of the for real world\n 6718 05:30:18,623 --> 05:30:19,623 to say that in creating this application beside\n 6719 05:30:19,623 --> 05:30:20,623 so far, we are also going to learn a lot of\n 6720 05:30:20,623 --> 05:30:21,623 we create the application. Okay, now let's\n 6721 05:30:21,623 --> 05:30:22,623 to create an application that will help the\n 6722 05:30:22,623 --> 05:30:23,623 application, we are going to show a list of\n 6723 05:30:23,623 --> 05:30:24,623 can see the details of that book. later on.\n 6724 05:30:24,623 --> 05:30:25,623 to different lists, for example, at least\n 6725 05:30:25,623 --> 05:30:26,623 this book, or maybe a wish list or also a\n 6726 05:30:26,623 --> 05:30:27,623 on in the course. In the process of creating\n 6727 05:30:27,623 --> 05:30:28,623 all of our knowledge about user interface\n 6728 05:30:28,623 --> 05:30:29,623 learn about a lot of new concepts. After watching\n 6729 05:30:29,623 --> 05:30:30,623 the application that we create together and\n 6730 05:30:30,623 --> 05:30:31,623 So I highly suggest that you watch this section\n 6731 05:30:31,623 --> 05:30:32,623 more talking, let's create our project and\n 6732 05:30:32,623 --> 05:30:33,623 to start with empty activity as before. Let's\n 6733 05:30:33,623 --> 05:30:34,623 library. For the other fields in here, I'm\n 6734 05:30:34,623 --> 05:30:35,623 name, once again, I'm going to put my website's\n 6735 05:30:35,623 --> 05:30:36,623 name, which is my library to save location\n 6736 05:30:36,623 --> 05:30:37,623 save with API level 19. For the minimum SDK,\n 6737 05:30:37,623 --> 05:30:38,623 so I'm not going to check this option in here.\n 6738 05:30:38,623 --> 05:30:39,623 working on our layout file. Before everything,\n 6739 05:30:39,623 --> 05:30:40,623 into my project, because we are going to need\n 6740 05:30:40,623 --> 05:30:41,623 go to this Developer tab. Let's select Android\n 6741 05:30:41,623 --> 05:30:42,623 Let's copy this line of code. We have done\n 6742 05:30:42,623 --> 05:30:43,623 anything here in our Gradle scripts, build\n 6743 05:30:43,623 --> 05:30:44,623 Let's add that. And also the latest version\n 6744 05:30:44,623 --> 05:30:45,623 And let's sync our project. It seems like\n 6745 05:30:45,623 --> 05:30:46,623 First of all, let's change the style of our\n 6746 05:30:46,623 --> 05:30:47,623 of this app compat theme, I'm going to use\n 6747 05:30:47,623 --> 05:30:48,623 Let's close this. And let's switch to our\n 6748 05:30:48,623 --> 05:30:49,623 is going to have multiple pages later on,\n 6749 05:30:49,623 --> 05:30:50,623 or to be specific multiple activities. But\n 6750 05:30:50,623 --> 05:30:51,623 or the first activity of our application.\n 6751 05:30:51,623 --> 05:30:52,623 I'm going to have a text view for the name\n 6752 05:30:52,623 --> 05:30:53,623 to add a few buttons. One for the list of\n 6753 05:30:53,623 --> 05:30:54,623 of books by clicking on this button. I'm going\n 6754 05:30:54,623 --> 05:30:55,623 them. Let's also add an image view above in\n 6755 05:30:55,623 --> 05:30:56,623 with one of our avatars. And also I'm going\n 6756 05:30:56,623 --> 05:30:57,623 Let's give some ideas to our elements. For\n 6757 05:30:57,623 --> 05:30:58,623 it's going to be our logo. For the TextView\n 6758 05:30:58,623 --> 05:30:59,623 that we need an ID for this one. This button\n 6759 05:30:59,623 --> 05:31:00,623 our books. So let's say btn all books. Also,\n 6760 05:31:00,623 --> 05:31:01,623 see all books. Beside that I don't like that\n 6761 05:31:01,623 --> 05:31:02,623 can change that you need to search for all\n 6762 05:31:03,623 --> 05:31:04,623 Let's change it to false. Now you can see\n 6763 05:31:04,623 --> 05:31:05,623 second button, I'm going to change its ID\n 6764 05:31:05,623 --> 05:31:06,623 is going to show the list of the books that\n 6765 05:31:06,623 --> 05:31:07,623 currently reading. And let's change the text\n 6766 05:31:07,623 --> 05:31:08,623 let's change the text all caps value to false\n 6767 05:31:08,623 --> 05:31:09,623 change its ID to btn already read because\n 6768 05:31:09,623 --> 05:31:10,623 that the user already read. So let's say btn\n 6769 05:31:10,623 --> 05:31:11,623 read books. Once again, let's change the text\n 6770 05:31:11,623 --> 05:31:12,623 button, I'm going to change its ID to btn\n 6771 05:31:12,623 --> 05:31:13,623 because this button is going to show the list\n 6772 05:31:13,623 --> 05:31:14,623 list. Basically, this is the wish list. Let's\n 6773 05:31:14,623 --> 05:31:15,623 list. Let's change the all caps attributes.\n 6774 05:31:15,623 --> 05:31:16,623 to change its ID to btn favorite books, let's\n 6775 05:31:16,623 --> 05:31:17,623 to say see your favorites. Once again, let's\n 6776 05:31:17,623 --> 05:31:18,623 last button, I'm going to change its ID to\n 6777 05:31:18,623 --> 05:31:19,623 we are going to show a dialog in which we\n 6778 05:31:19,623 --> 05:31:20,623 let's say within about, and let's change its\n 6779 05:31:20,623 --> 05:31:21,623 to change its all caps attributes, because\n 6780 05:31:21,623 --> 05:31:22,623 an ID to this text view as well. Let's see.\n 6781 05:31:22,623 --> 05:31:23,623 to developed by mesa@miko.org. I'm also going\n 6782 05:31:23,623 --> 05:31:24,623 Let's search for text style. Let's change\n 6783 05:31:24,623 --> 05:31:25,623 the text of the first text view to the name\n 6784 05:31:25,623 --> 05:31:26,623 my library in here. Later on, we will change\n 6785 05:31:26,623 --> 05:31:27,623 add our constraints. Also, you can see that\n 6786 05:31:27,623 --> 05:31:28,623 feel free to use the relative layout or linear\n 6787 05:31:28,623 --> 05:31:29,623 layout. So I'm using constraint layout, let's\n 6788 05:31:29,623 --> 05:31:30,623 top of maybe 70 dP for this image view. But\n 6789 05:31:30,623 --> 05:31:31,623 because right now I cannot see that. Okay,\n 6790 05:31:31,623 --> 05:31:32,623 would be better. Now let's concentrate our\n 6791 05:31:32,623 --> 05:31:33,623 And also to the both side of our screen. We\n 6792 05:31:33,623 --> 05:31:34,623 50 dP will be fine. It seems too much, let's\n 6793 05:31:34,623 --> 05:31:35,623 buttons. For this one, I'm going to constraint\n 6794 05:31:35,623 --> 05:31:36,623 to both sides of my screen, I need the margin\n 6795 05:31:36,623 --> 05:31:37,623 the second one, I'm going to fast forward\n 6796 05:31:37,623 --> 05:31:38,623 if the items are too close to each other as\n 6797 05:31:38,623 --> 05:31:39,623 by right clicking we can use this right click\n 6798 05:31:39,623 --> 05:31:40,623 to bottom between all books. Let's add a margin\n 6799 05:31:40,623 --> 05:31:41,623 I think 16 would be fine. It seems too much.\n 6800 05:31:41,623 --> 05:31:42,623 For this last TextView in here, first of all\n 6801 05:31:42,623 --> 05:31:43,623 my screen. And also beside that I'm going\n 6802 05:31:43,623 --> 05:31:44,623 screen so that it would be centered. Also,\n 6803 05:31:44,623 --> 05:31:45,623 that seems better. For this image view, I'm\n 6804 05:31:45,623 --> 05:31:46,623 going to show the actual image. I have prepared\n 6805 05:31:46,623 --> 05:31:47,623 that I'm going to copy this image. Let's add\n 6806 05:31:47,623 --> 05:31:48,623 right click and paste I think the name is\n 6807 05:31:48,623 --> 05:31:49,623 For this image view, if you click on that,\n 6808 05:31:49,623 --> 05:31:50,623 this tools source compat and instead of that,\n 6809 05:31:50,623 --> 05:31:51,623 that we just added into our project. It seems\n 6810 05:31:51,623 --> 05:31:52,623 manually. Let's see 150 dP I think that's\n 6811 05:31:52,623 --> 05:31:53,623 seems a little bit better. For this mind library.\n 6812 05:31:53,623 --> 05:31:54,623 font family. Let's search for that in the\n 6813 05:31:54,623 --> 05:31:55,623 arrow more fonts. Let's search for a good\n 6814 05:31:55,623 --> 05:31:56,623 and you can use them in your projects free\n 6815 05:31:56,623 --> 05:31:57,623 let's add font to our project. And let's press\n 6816 05:31:57,623 --> 05:31:58,623 Let's also increase the size a little bit.\n 6817 05:31:58,623 --> 05:31:59,623 14 sp, let's say 18. So that seems better.\n 6818 05:31:59,623 --> 05:32:00,623 this layout file is the width of all of these\n 6819 05:32:00,623 --> 05:32:01,623 width right now you can see that these have\n 6820 05:32:01,623 --> 05:32:02,623 let's switch to a split view. Once again,\n 6821 05:32:02,623 --> 05:32:03,623 say 200 DPI, I think that would be fine. Yes.\n 6822 05:32:04,623 --> 05:32:05,623 you can see that it's much better now. Okay,\n 6823 05:32:05,623 --> 05:32:06,623 page of our application. Let's quickly initialize\n 6824 05:32:06,623 --> 05:32:07,623 double shift, you can search for main activity\n 6825 05:32:08,623 --> 05:32:09,623 Let's also initialize these buttons down below\n 6826 05:32:09,623 --> 05:32:10,623 do that inside another method, let's say you\n 6827 05:32:10,623 --> 05:32:11,623 by pressing ALT plus enter. Once again, I'm\n 6828 05:32:12,623 --> 05:32:13,623 By clicking on each one of these buttons beside\n 6829 05:32:13,623 --> 05:32:14,623 user to another activity. Up until this point,\n 6830 05:32:14,623 --> 05:32:15,623 was named main activity. But if we want, we\n 6831 05:32:15,623 --> 05:32:16,623 as well. We are going to talk about activities\n 6832 05:32:16,623 --> 05:32:17,623 an activity is really simple. There are a\n 6833 05:32:17,623 --> 05:32:18,623 will talk about them later on. But in here,\n 6834 05:32:18,623 --> 05:32:19,623 do something like this in your project inside\n 6835 05:32:19,623 --> 05:32:20,623 can right click on that by saying new activity.\n 6836 05:32:20,623 --> 05:32:21,623 The names of some of these activities may\n 6837 05:32:21,623 --> 05:32:22,623 we created our project. But basically in here,\n 6838 05:32:22,623 --> 05:32:23,623 select this gallery, in which you will get\n 6839 05:32:23,623 --> 05:32:24,623 Let's select empty activity. Once again. In\n 6840 05:32:24,623 --> 05:32:25,623 in here is that to use the keyword activity\n 6841 05:32:25,623 --> 05:32:26,623 and also other strange characters. For the\n 6842 05:32:26,623 --> 05:32:27,623 name it all books activity, because this is\n 6843 05:32:27,623 --> 05:32:28,623 to navigate the user when the user clicks\n 6844 05:32:29,623 --> 05:32:30,623 You can also see a checkbox in here it says\n 6845 05:32:30,623 --> 05:32:31,623 for your activities, it is possible to create\n 6846 05:32:31,623 --> 05:32:32,623 the XML file. We will talk about that in the\n 6847 05:32:32,623 --> 05:32:33,623 do need a layout file. So I'm going to leave\n 6848 05:32:33,623 --> 05:32:34,623 when I changed the name of my activity, also\n 6849 05:32:34,623 --> 05:32:35,623 name, you cannot use upper cases letter. And\n 6850 05:32:35,623 --> 05:32:36,623 cases. Beside that you cannot have spaces.\n 6851 05:32:36,623 --> 05:32:37,623 that if this activity is going to be a launcher\n 6852 05:32:37,623 --> 05:32:38,623 one of the activities can be launcher. Right\n 6853 05:32:38,623 --> 05:32:39,623 is this main activity. It means that when\n 6854 05:32:39,623 --> 05:32:40,623 is going to be shown. And for that I'm not\n 6855 05:32:40,623 --> 05:32:41,623 if you don't check this option in here, if\n 6856 05:32:41,623 --> 05:32:42,623 manifest file later, but more on that later\n 6857 05:32:42,623 --> 05:32:43,623 we are going to create this activity in our\n 6858 05:32:43,623 --> 05:32:44,623 once again, I'm going to use Java. Let's finish\n 6859 05:32:44,623 --> 05:32:45,623 happened in our project. So first of all,\n 6860 05:32:45,623 --> 05:32:46,623 you can see that we have this all books activity\n 6861 05:32:46,623 --> 05:32:47,623 folder, in the layout folder, we have this\n 6862 05:32:47,623 --> 05:32:48,623 has been created by the Android Studio. Beside\n 6863 05:32:48,623 --> 05:32:49,623 this Android manifest dot XML, you can see\n 6864 05:32:49,623 --> 05:32:50,623 new activity tag in our application tag, it\n 6865 05:32:50,623 --> 05:32:51,623 If you want to create your activities yourself\n 6866 05:32:51,623 --> 05:32:52,623 possible. Basically, you can create a java\n 6867 05:32:52,623 --> 05:32:53,623 file. And beside all of these, you need to\n 6868 05:32:53,623 --> 05:32:54,623 the manifest file. Also, you need to link\n 6869 05:32:54,623 --> 05:32:55,623 method. We will take a look at that in a minute.\n 6870 05:32:55,623 --> 05:32:56,623 the help of Android Studio. Okay, let's close\n 6871 05:32:56,623 --> 05:32:57,623 all books dot XML file, you can see that in\n 6872 05:32:57,623 --> 05:32:58,623 design for this activity. In this video, I'm\n 6873 05:32:58,623 --> 05:32:59,623 instead, I'm just going to change its background\n 6874 05:32:59,623 --> 05:33:00,623 once again, you can see that we have a constraint\n 6875 05:33:00,623 --> 05:33:01,623 constraint layout, I'm going to say background,\n 6876 05:33:01,623 --> 05:33:02,623 I think I'm going to pass this color accent.\n 6877 05:33:02,623 --> 05:33:03,623 that we have navigated the user from the main\n 6878 05:33:03,623 --> 05:33:04,623 now let's see how we can navigate the user.\n 6879 05:33:04,623 --> 05:33:05,623 all books activity dot XML file, and also\n 6880 05:33:05,623 --> 05:33:06,623 that we are going to navigate the user to\n 6881 05:33:06,623 --> 05:33:07,623 all books activity, so we need to create an\n 6882 05:33:07,623 --> 05:33:08,623 books that set onclicklistener. Let's pass\n 6883 05:33:08,623 --> 05:33:09,623 method is the place to write the logic to\n 6884 05:33:09,623 --> 05:33:10,623 an object that I have never used so far, and\n 6885 05:33:10,623 --> 05:33:11,623 that it's coming from Android dot contents\n 6886 05:33:11,623 --> 05:33:12,623 intent is equal to new intent. It's a simple\n 6887 05:33:12,623 --> 05:33:13,623 any other Java class. The constructor of this\n 6888 05:33:13,623 --> 05:33:14,623 need to pass a context in here, because we\n 6889 05:33:14,623 --> 05:33:15,623 by now we know that activities are context,\n 6890 05:33:15,623 --> 05:33:16,623 pass that main activity dot this. After that\n 6891 05:33:16,623 --> 05:33:17,623 you want to navigate the user to for example,\n 6892 05:33:17,623 --> 05:33:18,623 So this way, we are saying that this intent\n 6893 05:33:18,623 --> 05:33:19,623 to all books activity. After that when we\n 6894 05:33:19,623 --> 05:33:20,623 in here called start activity, you can see\n 6895 05:33:20,623 --> 05:33:21,623 And we can pass our intent safely. This start\n 6896 05:33:21,623 --> 05:33:22,623 view by ID which exists inside every activity.\n 6897 05:33:22,623 --> 05:33:23,623 that when we click on this button, the user\n 6898 05:33:23,623 --> 05:33:24,623 quickly test that. Right now you can see that\n 6899 05:33:24,623 --> 05:33:25,623 of all, we cannot see this license TextView\n 6900 05:33:25,623 --> 05:33:26,623 here. And also beside that this currently\n 6901 05:33:26,623 --> 05:33:27,623 We will increase the width of all of our buttons\n 6902 05:33:27,623 --> 05:33:28,623 see all books button, we can see that we are\n 6903 05:33:28,623 --> 05:33:29,623 if you press this back button. Once again\n 6904 05:33:29,623 --> 05:33:30,623 It seems to be working perfect. Let's quickly\n 6905 05:33:30,623 --> 05:33:31,623 finish off this video in our activity main\n 6906 05:33:31,623 --> 05:33:32,623 the margins. For example, this margin top,\n 6907 05:33:32,623 --> 05:33:33,623 margin top of this my library text. Let's\n 6908 05:33:33,623 --> 05:33:34,623 for all of my buttons. Instead of 200 dP,\n 6909 05:33:34,623 --> 05:33:35,623 the first one, let's say 230 dP. Let's run\n 6910 05:33:35,623 --> 05:33:36,623 if we have fixed the issues successfully.\n 6911 05:33:36,623 --> 05:33:37,623 enough for this video. Just before I finish\n 6912 05:33:37,623 --> 05:33:38,623 source code for this application@maker.org\n 6913 05:33:38,623 --> 05:33:39,623 you need I upload the source code at the end\n 6914 05:33:39,623 --> 05:33:40,623 see your feedback. Okay, in the next video,\n 6915 05:33:40,623 --> 05:33:41,623 for our books beside that we will create a\n 6916 05:33:41,623 --> 05:33:41,639 show a list of different books inside the\n 570479

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.