Android App Development in Java All-in-One Tutorial Series (4 HOURS!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's going on everybody welcome to your Android programming tutorial series so what is Android well it is the operating system that powers the Android phones so if you want to develop apps for this this is the series for you now you might be an iPhone user and you might prefer that but as a developer you often need to know how to develop for both because a company usually wants their application on Android and on on the Apple Store so that's my goal here I'm going to try to teach you how to develop an Android in this series and then later on we're going to be teaching you how to develop on Apple in a future series so please be sure to subscribe if you're looking forward to that now if you're new and you don't really know how my videos work let me explain I'll keep it real simple concepts I go in the computer code real simple you don't have to know anything because this is a beginner series but I also will be teaching some some Java stuff so if you're new to Java and we're going a little fast I have another Java series if you just want to dedicate yourself to that and focus on that because Android development is basically taking that Java programming and applying it to building an app for a phone so you kind of have to learn two things here Java and app development so it might be a lot but you can commit and you need to commit because just a little stat for you guys based on my analytics my average watch time people usually make it about 3 minutes and 30 seconds into a video before they drop off and then from video 1 to video 2 the drop off is tremendous so most people fail so if you make it to video 2 you're already doing better than the majority of the people watching this episode so that that's not to encourage you to only get to episode 2 I would like to see you guys work all the way through because we're going to take you from out knowing absolutely nothing to knowing how to build basic Android applications again this is a beginner series so we're not going to be building some crazy complex stuff but I'm going to try to go a little bit farther than what most people would cover in in a beginner series and I'm to try to go at a depth that is more satisfying so I'm really excited and what we're gonna be doing now is we're going to be going over some of the Android principles that you need to know and some of the Java principles will install everything we need and then we'll start developing basic applications and learning the principles behind that now do you have to have an Android device look I'm borrowing this from a friend I don't own this I don't own an Android device myself and I'm still able to do this series and that's made possible thanks to what are known as emulators so these is basically like imagine having this on your computer and you can click the buttons and it's almost like a real device now before you go deploying applications to the the applications store or the the Google store or whatever you're going to call it you probably want to test it out on some real devices so borrow some from some friends and be like hey come check out my app you know try it out on there and I'll be showing you guys how to do that as well so hopefully after this series and the upcoming series you can have an application on the Play Store and on the Apple Store and on every other App Store there is on the market so thank you guys for watching and one last thing this is Java another language you might hear is Kotlin this is an alternative available for you to develop in Android applications we're going to start with Java but my intention is also to cover Kotlin and another upcoming series so I think this is a great place to start and then picking up Collins going to be real easy so thank you guys and also no sponsors for this series so I know you guys have been complaining about that and I listened more like no one wanted to pay me money so sponsor free so if you want to help out please be sure to check out my patreon account and start supporting this channel thank you guys and I don't feel like editing so I'm just gonna turn the camera off right here dang it that didn't work hey welcome back to episode 2 in your android development series I wanted to share with you guys some basic concepts of app development so we're gonna try and kind of zoom out a little bit and look at the big picture so we start with what we said earlier if I can find it Android this is one specific device but oftentimes as a developer you'll want to create an application for a numerous - Android and Apple so in this situation how can you do this if Java the language we're using only develops applications for this well here's a couple of options let's draw some stuff out so we have Android and for us we're going to be using Java you can also use Kotlin so these are your options for Android but we're gonna stick with Java and then we also have Apple or I guess let's just say iOS is probably the better use and for this we could use Swift you can also use objective-c but Swift is probably what's recommended all right so when we are learning Java and developing Android apps we're really only covering like 50% of the picture even though Android is the more popular operating system oftentimes companies will want to get their applications on iOS even so more than Android sometimes so you have to basically adapt to be able to create apps for both so here's how you can do that best one you can learn Java learn the principles of app development and then do that again for Swift and when you're doing this you can you can follow different design patterns that if you're creating an application that you want to be on both Android devices and iPhone devices or Apple devices then you can design it in such a way that you can share certain components now this doesn't always work but it can so for example instead of having two completely separate applications you could have two smaller applications that share one back-end that feeds both of these applications that's one way you can do it so for example if you're using an application you know like let's say you go you go on Instagram this might be instagrams servers and then you just kind of have like a viewer on Android and a viewer on iOS so you can basically only code a little bit for Android and a little bit for iOS and then code the easy stuff that's common between the two in some other language or whatever it might be so for example you could do this and nodejs or you could do it in Java or whatever you decide that doesn't really matter because there's a separation here you can think of it as two different components separation of concerns is what that's called it's a long word so basically if you implement things to allow for separation of concerns you can develop the Android application in isolation and you can develop the backend in isolation and then all you got to do is communicate between the two same for the iOS app you can develop that as its own thing and communicate to that back-end so that is one way of doing it and now I need to get my eraser I'm trying to reduce my editing because I find that I hate editing and it makes me want to not make videos so if I stop editing then I make more videos everyone's happy another option is to use a tool that allows to develop one code base that will then transpile to to be native apps so for example an option is flutter another option is react native and what these will do this will allow you to code one thing and then this gets deployed to ios and android so we'll say androids on this side go to Android and iOS so and this in the example of flutter you can use the dart programming language in the example of react native you can use JavaScript using react so if you want to develop your application in JavaScript and then just have it magically work on Android and magically work on iOS without having to know Swift or Java that is how you can do that same thing for flutter you encode one code base another popular one is xamarin if you know C sharp so the thing that's special about these is that the end result is a native application when someone says native what they mean is that it's not like a web app that looks like an application but it's really not it's native is as if you programmed it directly on Android and directly on iOS so there's no issues for speed or anything like that now a third option so if you're not going to do Java and Swift and you're not going to do this a third option is to do a web app so with a web app you can build a website that looks and performs just like an app so you can use it on your mobile devices just the same by going in the browser visiting that web page and it works fine or you could even create a shortcut to that website on the the phone's home page so sorry I don't know how to use these so you can make a shortcut button on here that when you click it it opens up to that that web app and it works just fine so that's a third option and there are some other options out there like reactive applications this is another thing you can look into there's all kinds of different application options and there there's so many different ways to do it so what am I trying to get out of seven minutes into this rambling session I hope you have just a better view of the different options that are available to us which one should you choose I think it doesn't matter unless your boss tells you to do this one I think the best idea is to just pick one start with it and get better at it because for example once we learn how to do Java and Android picking up the other ones is going to be a whole lot easier because we're already going to understand the different components of the Android applications and that's going to be very similar if you switch to something like flutter or react native you're going to still have to worry about those components they might just have little different names a little different way of working with them but your overall app development skills are going to be a lot better so that's where we're starting I I have grown to prefer just doing it natively I personally feel like there's a little bit less risk now a lot of people have developed with tools such as xamarin and react native and it works fine but I think there there is a little bit more risk because now you're relying on a system that is external to Apple or Android and you have to abide by what they allow which means maybe you don't get the the latest greatest features that are available on a new operating system releases or maybe there's there's some bugs in their software that makes it hard to create a certain app so there's different issues that arise and although it's perfect - it's it's ideal to think in a perfect world you know we create one code base and it magically just works on Android and iOS but that's not always reality you can have issues that that arise that might not arise if you're developing native on iOS or Android so that's why I think personally it's probably best to just start developing natively yourself on a mobile device in this case Android using Java or Kotlin and if you're on iOS using Swift so that's where we're starting hopefully that makes sense with you guys and if you have any questions or concerns about which direction you should go I would like to start some discussion in the comments section of this video let's hear what experience you've had with these different ways of creating applications and which ones have worked best for you or which ones you would advise against because different people are going to have different experiences and some people are going to love a tool such as react native and other people are going to absolutely hate it so let's hear some of your stories if you've done any app development in the past or as you're going through the series maybe you try one and it's not what you're hoping for then then come back to this video and leave a comment in that comment section below and the only other requests I have is to subscribe to help this channel you know I got to be that number one coding Channel so I got got it quite a bit of a ways to go and also consider supporting me on patreon and thank you peace out wow you guys made it to episode 3 which is actually impressive after that rather scatterbrained episode number 2 so thank you guys for sticking along this far I think you guys are doing well and pretty soon we're gonna get hands-on but there's a couple more concept things I want to cover just so we can kind of set that foundation so when we start coding things everything makes good quality sense alright so a couple things when we're working with an Android device there's a couple of terms or vocabulary that you should know so you have a bunch of application options so each one of these is an app and each page on this application is known as an activity so when you open an application you have the the main activity and this is interesting I like that they used this word so the main activity so if you watched my java programming series or you have some history of programming experience you might know that oftentimes for programming languages the the application will start in what's known as the the main function or the main method so main is a common thing in software development whenever you see main think of it as the start so in other words the main activity is kind of like your homepage for your app then on that homepage you can have different buttons that will actually open up a new activity so you can basically think of an application as a series of pages and you can display different pages depending on on what you want to do now a key thing with these applications is that you can open open the application to a specific activity based on how the application was opened so for example you might send the person's phone a notification and say hey Sally commented on your photo and then they click that and it doesn't go to the main activity instead it goes to the activity for that photo so it can it can change which activity is opened to based on how you open the application you can also have it be open from other applications which will allow you to to go from one app to another to a specific activity so that's one really cool capability of these applications now another thing is that there is a level of dynamic miss that is made possible when you're developing Android applications so for example you might have an Android device that is this big and I might have an Android device that's bigger you can I'm having the bad habit of I'm looking at the screen here instead of I got a look at the okay so you could have one that's bigger and you can make the app dynamically resize to fit the the larger phone also different phones are going to have different hardware capabilities or different features based on what model of phone they are or which manufacturer Android is really challenging and understanding all this because so many different phones have Android it's not like Apple where you just have the Apple phones that has iOS so all you have to worry about is the iPhone the different years or the models of the iPhone and then the tab the i/o iPad and then that's it instead you have to worry about all the different phones that have Android which there are tons of them so all different sizes and all different capabilities so you need to be able to create applications that are dynamic that are going to work on all of these devices so a couple ways you can do this is one design your user interfaces to be dynamic so that that way they work on these different sizes of devices and test it out you can get emulators for all the different devices you're going to need to create for check them make sure everything looks good play with them and so forth the other thing is that you can check different hardware capabilities so for example the app might require the access to the camera and if for some reason a phone doesn't have the hardware camera then you can make it so that the app cannot be downloaded these are the kinds of capabilities that are made possible you can basically check to the hardware capabilities and you can either make it so that they can't use the app if they don't have it or you can disable a particular feature you know maybe the camera is optional and since they don't have one we'll just turn that feature off and we'll just not use the camera so I guess it depends on on what specifics you need what you want to do but that's the kind of stuff we're going to get into now there's one last keyword I want to teach you guys and we're gonna get into this in a dedicated video but when I first started this is a word that tripped me up so many times and I want you guys to just see it so it's in the front of your brain or at least in the back of your brain deep back in there like back with like the math you learned in school put this word there at least but hopefully it's up front because you're going to see it again and basically I want you to think of an intent as a way to do various different things inside of Android development so we're going to get into all the different things that can do but for now just know that this word exists and I'm going to give you one example of something you can do with an intent let's say you have an activity such as the main activity and then you have another activity that is opened when you click this button so you click the button and a new page is open with all new different options and buttons and so forth well you can basically transfer data from this activity to this activity using an intent so it's a way you can transfer data between activities so that's one of the things and intent can be used for but there are a lot of different other things so the easiest way to learn this is through example so we'll be going over lots of examples so that's all I wanted to talk about in this episode we talked about three things activities including the main activity we talked about the dynamics of Android development and we talked a little bit on intense just to get that in your brain because we're gonna be seeing that and I don't want it to be brand fresh brand new fresh when you first see it and start using it I want you to have a little bit of knowledge so if you want a little bit of extra research practice look up intents and Android read upon them see what they can do and and you'll realize that they're quite versatile and you'll probably be using them a lot other than that I think that's pretty much it the only thing is in order to view number four you have to subscribe to the channel it's the new rules on YouTube that's how it works I'm just fine but I would really appreciate it if you subscribe and help this channel grow and yeah that's pretty much it also consider supporting me on patreon peace out and check out the next episode where I'm going to give you some more highly useful and entertaining information and pretty soon we're gonna be making like I don't know probably the next flappy bird we're gonna be like big shots so stay tuned and I'll see you in the next one hey welcome everybody in this episode we are going to be getting the tools needed to start android development so specifically we're going to be downloading android studio now Android studio is an example of an IDE and an IDE stands for integrated development development environment and here are some other examples of IDE you've may have heard of some of these Visual Studio Eclipse Xcode essentially it's a glorified text editor so instead of doing everything inside of notepad plus plus we can get a little bit more capabilities and features that are built around whatever software we're building so in a situation of Android this IDE is going to give us access to emulators for different cell phones it's going to do some you know syntax highlighting and all of that good stuff for us so it's just a little bit cleaner than using a very simple text editor so it's going to have all of the compiling capabilities and everything built into it so let's go ahead and get that now I did originally have all this stuff installed on my machine but I tried to delete everything just to go through the whole process but it might be just slightly different than you guys but you should be able to figure it out just with a little bit of effort and research and yeah so make sure you read all this good stuff here nice and juicy download that and that should start downloading and while this downloads I'm just gonna take a minute to just complain a little bit and give you guys some advice so when you are building apps try your best not to create a new release of an application that's actually worse than the previous so why am i bringing this up well I actually record all of my videos with this tool called QuickTime and that's actually what this little square or circle logo is here the circle with the square inside of it that's to say it's recording and they just came out with this new addition and it's just it's just not good because for one it doesn't indicate when it actually starts recording because there's like this three-second delay so I just kind of have to gasps when it actually started so it might actually cut off a little bit of my words or it might actually like you know have like a second or two of me just like breathing really heavily which I don't want either one of those but there's no real easy way to change that as well as I used to have microphone levels so I could check how loud my microphone was by speaking into it and I'd see it go up to the red and see where if it was good or not but now that's gone as well so here's an example of what not to do don't create a really good application that's free for use and then make it terrible and useless I mean it still works but if you guys have any other recommendations for screen recorders I have to use Camtasia before but it's just a little it's a little big for my needs I just want something real simple I can just record and I can immediately take it and upload it to the internet and as you can see my battery is low so this looks like it just about finished yeah perfect timing so let's open that up and sorry to complain guys I just wanted to get that off my chest because oh no it's annoying for consumers after using an app for so long that they make key changes that destroy some of the the most valuable pieces of the software and it seems like developers do that all the time like I don't know why developers think it's a good idea to make software worse or if they just don't understand how users work but yeah take this I'm on Mac if you're on Windows it's gonna be a little bit different but this shouldn't be too bad just go through the the the process of installing it and that'll go into your applications and if you have the option to do like a desktop shortcut or whatever go ahead and do that on Mac that's going to appear in the Applications folder so you can double click that or you can hit the f4 key and see all of my applications go in here and click Android studio and hopefully I can finish some time my battery is getting a little low so we'll minimize these and we'll just have Android studio open yes we want to open it I trust the developers here and just give it like an hour - you know how it is all right so it's going to to pop open and this should guide us this should have everything we need to to create applications we might need to go download what's known as the JDK the Java development kit I'm not sure if Android studio comes with that already or if that's something you need to go download separate but if we start creating applications and they work then I know we're good because I actually uninstalled the JDK right before starting this video so if for some reason you're trying to run your applications and it's something's not working it's just saying like hey it doesn't have the capabilities to run this or something then go download the JDK all right so when you get here you should create a new Android studio project and you have a bunch of different options in here and we'll just go with an empty activity now as a refresher from the previous episode inactivity is the equivalent to a page so we're just going to have an empty page on here we'll click Next and give it a name my application for the language we're gonna go with Java but again you can also look into Kotlin if that's something you're interested in and yeah that looks good we'll just click finish and this should give us everything to basically have an application that doesn't actually do anything so what we're gonna do is we're going to make this full screen and ignore the low battery thing so I'm going to try and finish this up real quick and if my battery dies I'm sorry guys now when you run the application you'll you'll go up to the top here and you'll see there's no real play button there is a play button right here but it's it's darkened out you can't click that and that's because you need a way to run this application it doesn't just run like it would if you were programming in Java and a console you need either an emulator to to act as a mobile phone or you need a mobile phone a physical mobile phone to plug into your computer and that's what we're going to be talking about next so as I let all this stuff spin and synchronize I'm going to stop the recording and in the next episode we're going to be talking about how to actually take our application and run it so thank you guys for watching please be sure to subscribe and I'll see you in the next episode and if you're interested check out my patreon account thanks peace out welcome back in this episode we are going to learn how to work with the Android virtual device thing so basically when you load Android studio it's gonna look something like this we've got a whole bunch of junk going on and we're gonna clean all that up but the one thing you'll notice is watch this alright first if you click this little arrow that's on time up AVD Android virtual device manager that's we're going to be talking about but first of all we're just gonna click this little play button we got our app started and it says air running app no target device found you can see that down in the bottom so what in the world does that mean it means we need to select a device to run this application on so we can't just run it on our computer like you would if you're in Eclipse programming Java you just run in and runs in the console boom everyone's happy it doesn't quite work that way with Android studio you actually have to have a location so you you go to select a device and look there's nothing on here except open AVD manager so that's what we're gonna start with alright so on here this is where you manage all of your virtual devices so by virtual devices it means they're not physical devices it just looks like you have the smart phone or the watch or whatever it might be on your computer and you can click around using your touchpad your mouse or whatever you're using so let's create a virtual device and you get a whole bunch of different phone options pop up here so you can see here are the pixel phones we have some of the nexus yada yada yada I'm not really a huge Android user I know Java obviously I know a little bit about Android development but my my day-to-day use phone at least of right now is an Apple phone so I don't know all the differences between all of these but hopefully that's then we can explore as the series goes on if we need to explore different options on here so we're going to start with the pixel phones and we're going to go with let's go with a pixel 3a that looks fun and then you click Next and select a system image all right so these system images wellthis these are basically the different editions of an of the Android operating system so you can select one on here and you can see over on the right what Android version it's talking about so they just have little code names so Q that's the latest one at least for me that is 10.0 now you can also see the the API level distribution chart you can also find it if you X out of this you'd there's a little link down here at the bottom and this is going to oh actually it doesn't even open up a new web page it just shows that all right here that's kind of cool so it's going to show which editions are the most popular so what I'm going to do is I'm going to close out of this and I'm also going to close out of this for a second because I want to show you this web page if you click this you can see this distribution dashboard where you can get a little bit more info about the the different distributions and if you just want a little bit more information you can use that web page as well so I'm going to exit out of that and we're going to go back to creating this and we're going to go with pixel 3a and click Next and then we're going to go with Q which is the Google Android Earth sorry the Android version 10 and then we're going to click download now of course you can create the application and you can test it out on these different versions so if you wanted to make sure your application worked on as many things as possible you could go down here and try downloading all of these different editions and then you could test run your application on all of them just be warned as you download all these different phones and all these different editions you're going to fill up a lot of space on your hard drive so you might need to keep that in consideration hopefully you have enough storage I'm on a 256 gigabyte laptop so I probably can't go download every single one of these so I'm just going to stick with one for now and then we'll explore from there all right it looks like this is done so we're going to do is we're going to hit finish then we'll hit next and then we can give this a name up that looks like a pretty good name I think I'll name my first child that pixel 3a API 29 you can choose a start up orientation a bunch of other stuff we'll just hit finish all right there we go so we have our device it works exactly like a smartphone it's really cool honestly I got into this kind of development long before I had a smartphone so it was actually kind of cool for me so you can watch this startup as if it's a normal phone and you can see there's all kinds of different button capabilities so since you don't have physical buttons it looks like some of them are over here so you can increase the volume or decrease it you can tilt the phone for different rotation capabilities you can take a screenshot zoom and then go back home and overview and more so lots of different capabilities there and it might be a little slow that's because you're running basically a system inside of a system and I'm recording the whole process so it's gonna be a little bit slow for me hopefully it's a little faster for you it just depends on what kind of machine you got and how how beefy it is I'm on the the base model 13-inch MacBook Pro from 2015 I think so it's been it's been a couple years about five years so Wow my goodness about time it started up so we launched this from the little play button here which isn't going to automatically launch our app if you want to do that which it's not gonna take nearly as long you can X out of your virtual devices and you can hit the play button right there and this is going to build and then it will show up over here on your device my computer literally sounds like it's gonna explode so sorry about that all right it looks like it loaded and you can see it says hello world so we didn't even have to type it out it just did a hello world for us so we got our first application you can go show it off probably get a job as a senior software engineer Android development whatever it is you got this to show them so but you're probably not going to get very far if you don't know how to run this on an actual Android device so that's what we're gonna be talking about next so please be sure to smack that subscribe button and check out the next episode hey what's going on everybody this episode I want to show you how to you be quiet we're going to be doing USB debugging with an Android device in other words how can we create an app on there we did the hello world app in an earlier episode how can we get this running on an actual Android device now we're not going to be deploying to the the Google Play Store and then downloading it that that you could do later on once the app is launched instead we're going to be using it on this in development mode so androids are kind of weird cuz they have like these secret settings that you can enable so pardon me I'm not like super great with Android but open your phone and then go to apps and here's we're gonna do we're gonna go into settings can you guys see all us probably go to system so if you're on like one of these scroll over go to system and then go to about device and there's one on here build number double click that a bunch of times and not double like seven time click and that's going to turn on development mode so then what you do is you click the back arrow and now you should have this developer options under system you can click that and USB debugging turn that on oh you have to turn the whole thing on if it's off alright so turn that on and then USB debugging on so can be used to copy data between your computer and your device bla bla bla bla bla bla all right awesome so that is step one next thing you need to do is you need to take this and you need to plug it in to your computer just so you know what developer options it gives you all kinds of different settings that you can configure and tinker with so go through on your phone and look through some of this because it kind of gives you some really cool capabilities with your phone that you normally know that otherwise wouldn't have probably didn't even know was there when I first did this I was like what what is going on how could you just do that so it's kind of weird that they just have that hidden in there it's kind of cool though because not everyone needs to go in there and development load because it probably just needs people to breaking their phone or causing issues so you don't just want to do it for everybody so next thing get a USB cable to your computer plug it into this if you're on Windows meaning you're developing on Windows you might need to install drivers and there's guides for that so I'm on the superior operating system start debate in the comments below I'm using Mac so I don't actually really have to do anything I just plug this in and it works so that's what I'm gonna do and if you guys are in Windows you can try if it doesn't work go into your your system settings or whatever and look for the drivers I haven't use the Windows computer in forever so well I guess a couple years ago but anywho my point is plug this in and we'll get started so that's we're going to do in the next episode we're going to take our hello world application and we are going to run it on an Android device so thank you guys for watching be sure to subscribe and I will see you then welcome back this episode we are going to take our application that we've created are a little hello world application and we are going to take it and run it on an actual physical Android device now you can't actually see the device but if you watch the previous episode you would know that I have an Android device and I'm gonna plug it in to the USB cable thingamajig and we're gonna see what happens now this here is an emulator that's going to work for the majority of our development but as we get closer to release you want to test it out on physical devices so also the emulator allows you to try on more devices so you don't have to go by tons and tons of different and cell phones with different versions and different sizes and so forth so forth so what we're gonna do is we're going to go over into Android studio and what we're gonna do is click the drop down here and you can see it says pixel 3a which I taught you how to install in the episode before the previous episode and what I'm gonna do now is I'm gonna plug in my phone so I plug in my phone does a little buzz thingymajig and it said unknown device for a second and then it popped up with samsung says some other junk so that is the device that we're going to run on so what I'm going to do I'm going to click run app alright so we went to the build so you can see the process here it takes forever and then it popped up on my phone and it says hello world so that's all you have to do to run this on Mac on the computer and Android on the device if you're on Windows you might have to do a little bit of extra work you can see this is a guide on installing USB drivers so you might need to go to computer management and then device manager and do all this other stuff if for some reason it's not working you might need to do this process here and make sure you follow the appropriate operating system probably Windows 10 but just in case you're on Windows 8 or Windows 7 you might need to do it a little bit differently alright so that is how you develop and try it out on your device it works exactly the same way as this emulator but it's on a physical phone so it's a little bit more realistic thank you guys be sure to subscribe and check out the next video cuz we're gonna start building out some applications or at least learning some good concepts you hey what is going on everybody welcome and this episode we're going to be covering a bunch of different things about Android development so if you're just jumping into the series this might be a good place to start because we're gonna start building apps now if you're brand new I'd actually encourage you to start this series from the beginning because we cover some essential foundational concepts that are that's going to set that that foundation for success but if you're just jumping in you want to go from here by all means go for I'm not going to tell you otherwise but basically what we're going to do in this episode is we're gonna talk some about the layout a little bit with working with Android studio and we're going to talk about the basics of the setup for an Android application so pay attention you don't want to slack off yet so what we're gonna do first off is if your screen looks a little bit different than mine maybe you have some stuff open or whatever it might be what you can do is you can go to window restore default layout so anytime you mess up your layout you can click that to get back to the default the next thing is when you open some code so if you go over to project and you open up one of these files let's just let me just open one it doesn't really matter you'll notice the text is really small really small in here and you might try a holding command or control on hitting the plus key like some other editors allow you to do and it doesn't work but what I can do is I can hold command and I can scroll in with two fingers or if you're on Windows you could just use like to scroll on the mouse or on the trackpad and that should work the same way but if you're trying that and it's not working let me show you how to make that work what we're gonna do is we're gonna go up to Android studio and go to preferences from Windows is probably somewhere similar and then what we're gonna do is go to editor general and there's this one here you can check which says change font size with command plus mouse wheel so make sure that's checked and hit OK now you should be able to scroll in so you can see it nice and easy beautiful now the next thing I want to talk about in this episode are some of the key files so if we just X out of this and take a look at our project over here on the Left close everything and just open up app now in here you're gonna see a lot of different files you can see one that says Java and then another one that says Java with a generated in parenthesis the one we're interested in is the Java without the parenthesis this is generated so we're gonna open this one and we're going to open that first folder my application by clicking the triangle to expand it and we're going to open the main activity now if you remember from an earlier episode the activities act as the different pages of your application so the code might look something like this your code should be pretty much the same it should be exactly the same honestly so this is what code we have so far when the application runs this is where it starts it starts on line 11 now there's another important file you should know about and that is if you open up the res folder and then layout and then activity underscore main XML so this is the structure of your application so there's two pieces for this activity there's the code for the activity and then there is the layout for the activity now when you're on this page this is going to be where you do your visual editing but if you want to build functionality you're going to be doing that inside of the java file the dot java so get your file extensions figured out you can see mainactivity.java that's for code activity underscore main to XML that is for structure XML defines the layout Java defines the functionality so for example this here is an example of a method and it defines what happens when the the first activity is created sorry guys and back I just threw up anyways boys lest saying oh yeah the dot Java file is the code for the application or the activity and the XML is the structure so get your file extensions figured out and understand where to find them and that is the basis because when we go and add new activities you'll know where to put them and which files go where and where everything happens so thank you guys for watching in the next episode we are going to be talking about something new so be sure to subscribe and I'll see you in the next one hey welcome back everybody this episode we're going to be talking about the layout editor and that is what you're looking at right here so if you want to figure out how to find this piece you need to open an XML file so inside of our project over here on the left you can expand app and then go into res and then layout and then open activity underscore main XML now this is an XML file now if you've ever seen XML before it's a markup language and you're probably thinking it doesn't look like this this looks like a user interface well what this layout editor does is it actually will show us the visual of what the XML will look like so if you want to see what the actual XML is there's a little button down here at the bottom that says text so this is what XML actually looks like and yeah it's kind of ugly I don't really like XML but it serves its purpose it's basically a way to structurally lay out an application and this is the the default XML and as we modify our activity or our page this XML will be updated with new content so you can see in here one of the items in here is this textview and then actually refers to this hello world a little text section right here so inside of our activity I'm sorry you can go back by clicking design inside of our activity you can take this you can drag it around and you can change different attributes of this thing over here on the right and that is all going to be represented inside of the XML so if I can give you a little bit more space you can see it has this 464 here if we go back to the design dragging around a little bit maybe go back to the text and you can see that changes as well as this one here as well so the position of the text is is put inside of the XML and we just get this nice visual what it looks like and as we change this you can see different things appear on the the textview xml and you can see if we get it perfectly in the middle you can see one of the the things disappears so if we pull it off to the side you can see the horizontal bias is there but if we put it right in the middle it goes away so the default is right in the middle there so if we want to get rid of the vertical we can put that right in the middle as well maybe if I can get it mmm there we go perfect so you can see if we get it right in the middle those go away because they default to putting it right in the middle so that's a little bit on how the XML works but now let's take a little bit more as some of the other pieces of this so at the top we have this toolbar and you can see we have two sections we have this blue section in this white section you can change that by clicking this button right here and this is known as the design surface so you can select this and you can choose design you can choose blueprint or you can choose both of them so I recommend to go with both of them but if you prefer one over the other or you have a small screen you just want to focus on one of them you can select that there the other things you can do is you can change the orientation of your phone so what it looks like whether it's wide or tall portrait or landscape you can change the phone to view it on so we could go to the pixel 3a if we want to see the shape of the the same as the emulator we downloaded and yeah those are the key things that you should know about on here other than that you can see over here we have this palette this allows us to take things different components and put them on our page so we can add buttons for example and we also have this component tree which describes the structure and then we have attributes on the right which allow us to change things about the the component we're working with so these components they're actually called views and we're going to talk about that more detail in the next video but for now just know that each one of these components we put on the screen is known as a view so that is the introduction to the the layout and if you want more information there is some good documentation here's an introduction to the layout editor you can see all of the different pieces and where they are and I'm sure you can read this if you uh if you want or you can just continue in this series says we're going to be going over all this information so hopefully that was helpful just as a basics to get you started the main thing you need to know is that these things are called views each of the views have attributes or things to describe them we can configure those there and all these configurations are actually stored in text in an XML format but and you can see that by clicking the text tab down at the bottom so hopefully that gets you started thank you guys for watching in the next episode we're going to go in a little bit more detail with these views and as well as layouts so be sure to check that out I'll see you then a welcome everybody in this episode we're going to talk a little bit more about views as well as layouts so these are two types of components that you need to know about an Android development so if you look down here on the left you can see this component tree and you see there's two things in this default application we have this constraint layout and then we have this text view so these are named nicely because you can see which one's a layout and which one is a view the layouts act as a a box to put views inside and the views are just different components that we can use inside of our applications such as a text thing or we can go in here we could add a button there's all kinds of different things that we can put in this application and you can see that they're all nested inside of this layout so again just to repeat myself the layout acts as a box to contain these views so numerous views go inside of the layout and you can visually see that because the the text and the button are indented just a little bit after the constraint layout so if you want to see another example of this let's get rid of that button just so we go back to how we had it and in the palette you can click these different tabs on the left let's go to layouts and add the top one constraint layout drop that on the screen and now we'll go into buttons and we will just add a button and you can see that this constraint layout is inside of this other layout and this button is inside of this constraint layout so you can collapse it using the little triangle there the little arrow and you can see that the button is inside so what that means is when we take this constraint and we drag it around you can see that the button is moved with it it's tied to it so consider it the button is inside the box and now we're moving the box and all of the stuff inside moves with it now as we go on in this series we're going to learn more about the different components for example what these different layouts are and with the different buttons and text types we're going to learn what all that stuff is so don't worry about that all right now the main thing you need to understand is how the different components work and the difference between a view and a layout now one other thing I wanted to touch on is that you can see we have these two different views we have the design and the blueprint I never really talked about what the difference is so I just wanted to give just a example that will show the difference you can consider the blueprint as more of the structure and you can consider the design as well the design what it's going to show up as so here's a little example if we go and we put a button on the screen and by the way you can just delete it by hitting the Delete key and let's say we go on here and mmm we say visibility and we set this to invisible well check this out you can see it on the blueprint but you can't see it on on the design so the blueprint shows it and the design does not so that's why I like having both because then you can see everything that's going on but it's nice because you can't you you you know it's there on the blueprint but visually you can see that it's not going to appear so that is the benefit of using these two at the same time so you can see both perspectives so that is the basics of views and layouts and a little bit more on working with these activities so hopefully this has been helpful for you guys stay tuned because we have a lot more coming and I am just stoked so please be sure to subscribe and I'll see you in the next episode hey what's going on everybody I just wanted to do a quick video to briefly talk about attributes so exciting now if you have prior object-oriented programming experience this video will be a piece of cake if you don't it might be a little bit of a learning curve but it really shouldn't be too bad because this concept is not hard but you're going to see attributes a lot so when we're working on an activity let's just say we're on the main activity and we have some view such as a text view that says hello world well this is the appearance this is the presentation but behind the scenes this thing has a ton of available attributes and if you come from object-oriented programming you may have heard of properties these are the same thing so if you if you want to understand this think of what an attribute is for example for a person you can describe a person such as me in numerous ways you can say they're incredibly intelligent they're extremely handsome and so forth these are the attributes that describe this person when it comes to a view we have other stuff but it works exactly the same way and all of this is going to be defined inside of the XML so if you remember the XML describes how this all appears so it's going to look something like this now I actually have it for reference over here because there's no way I can remember but we'll see if we'll see if I got it down so it looks something like this we have a text of you and then we have some stuff inside and then we eventually close it using a forward slash and a greater than sign I always forget which one I always have to do the alligator thing or or whatever and then inside of here you're gonna see something like this it's an Android and then a colon and then it'll have some attribute or property you can use those interchangeably but in this context it's more appropriate to say attribute but just so you understand they are the same concept so Android and then we'll have something like text and this is the text attribute which describes what the word that shows up is so we can say equals hello world now all of the syntax don't really worry about it you can worry about that later when you're advanced but the main thing you should know is that this here is double quoted and it's an example of a string so strings just quoted sequence of characters like so so the value that the string is describing does not include the quotes so it's just hello world and that's what's going to show up inside of the the activity all right so text is just one example of an attribute but there are a lot others so as another example we can have clickable so it might look like this we'll have clickable here and then equal true now in this situation it's not quoted because it's a different data type at least I think oh no it's actually quoted sorry alright so this is gonna be true I'm not gonna edit that out you guys you guys understand I make mistakes on occasion very rarely but from now from now time to time I'll make a mistake so in this situation we are setting the clickable attribute and this is all hard-coded in the XML and later we're going to learn how to change these values inside of the code but for now I just want you to understand that concept and this is going to be independent for each type of view so for example a button you know that's something you can click or poke that's going to have different attributes than text and all the other views are going to have different attributes as well and also if you have two of the same types of views so for example if we have a text view you know I have another text view these values are going to be set independently so this one's going to have its own value and this one will have its own value this one can have clickable true and this one can have clickable false it just depends on what you want for each individual view so that's your basics of attributes nothing too crazy and just so you guys know where to edit these you can type them out in the XML but I don't really advise that I think the best way is to just use the view when you're looking at the activity editor and you have something like this you select that it's going to pop up on the right and it's going to have the attributes and you can set the values there so that's your introduction to attributes now we're going to get hands-on talking about one of the most important attributes and that is actually an ID because we're going to be using the ID throughout entire series so we're going to learn how to set one of those and all that in the next video so go check it out thank you for watching and subscribe hey everyone welcome this should be a pretty simple video because all I really want to do is talk about one important attribute that you should know about and understand a little bit on how to work with it and that is the ID attribute now if you don't know anything about attributes be sure to check out the previous video and obviously if you're new to the series I'd encourage you to go back and watch the whole thing so that's definitely what you want to do but either way let's get started when you select something on here you can see that over here there is this ID and in this case it is blank now does it matter that it's blank well currently no it doesn't really matter because it's serving its purpose the only purpose this thing has are now is to say hello world yay it did it but later on we're going to want to reference this view so we can modify or work with it inside of code and in order to do things dynamically like that we often want to grab things using the ID so let's take a look first at the XML if you select text down here and you can X out of or minimize the stuff down here we can go to text and it should show up right here but it's not there's nothing about an ID here you can see these other properties or attributes I should say we have the text attribute here and you can go in here and you can change that and you can see how it changes over here on the right but there's nothing about an ID so you have one of two options you have two options I guess you can do one of them which is to set it manually in here which I don't really recommend but I'll just show you how it works just so we can get some use to the syntax say ID and then just say hello like so and it obviously doesn't really like that so let's maybe get rid of those mmm see I can't even do it right like this is why you don't do it in the XML because for one is just more work so let's go back to the design and we'll go over to the ID and we'll just say hello and we'll see what it generated so go back to the and oh you can see it actually is a little bit more fancy has this app plus which will uh probably get in that later I I'm not gonna I don't you know what that means but it's a thing you'll see that with the ID and you can see that this is what the actual ID value is now just for a little sneak peek you'll probably get to see this later on in the code so you might see something like our die ID yeah and then dot and then hello that is how we can get a reference to that object or to that view so this view here is actually an object and when we talk about it in code we'll probably refer to as an object now I'm just kind of jumping into the deep end here so don't worry about that too much cuz we're gonna be getting that in the upcoming videos because we really can't do any cool dynamic applications without working with the IDs and understanding a little bit how to do that inside of the code so we talked about first how to do it in in the XML and inside of the design and next we're going to learn how to work with the inside of the the code so yeah thank you guys for watching be sure to stay tuned for the next episode because we're going to get into more stuff thank you I'll see you then hey what's going on everybody this episode what do I want to talk about well I actually just want to talk a little bit about the concept of things being static or dynamic now this might not be a hundred percent focused on Android development but I think that's fine because I don't just want you to come out of this knowing how to create some apps but know nothing else about computers or programming I want to teach you that in a way that's going to help you in your entire career so this is going to be a really helpful video if you don't know this information already and if you do sorry but you can watch it where you can move on to the next episode so you will often hear the words static and you'll hear the words dynamic now the meanings of these what you think of them might depend on your age or when you got into computer programming or software development whatever you want to call it so let's go back for a long long time ago at least for me when web pages started being created there was what we're known as static web pages and dynamic web pages so a static web page you go on there it has some info about your website it might have a form for you to fill out for an email and then you know what happened next dynamic web pages boom the whole world exploded and everything changed because now instead of just having this information we could generate parts of the website so for example we could have the header that could be coded from one location we could have the footer that could be coded from another location and then we could generate the body and his body would come from a database so things changed things were dynamic and one of the real benefits of this is that you could create the content to be specific for particular users so rather than saying welcome you could say welcome Caleb or hello handsome or whatever you wanted to say well I guess handsome wouldn't be dynamic yeah Caleb would be dynamic because it would change depending on what your name is so that was the introduction of dynamic web sites and this really started with PHP and now every programming language you can create websites with so yeah that's the first dynamic now the second dynamic has to do more with the way things look so this also deals with websites but it also deals with apps so when you're talking about a dynamic look of a website you're talking about that the things resize or fit depending no matter what the the device you're viewing it with so if you're viewing it on a desktop it looks good you're viewing it on a mobile phone it looks good that's because the content is dynamic or a better word would be responsive to whatever device you so that's another way you might hear dynamic and the same thing for mobile phones and apps so if you open an app on a big fat phone it's gonna fill up the screen and look good if you view it on a tiny thing it should look good if you went on a tablet it still looks good so that is another way dynamic is used now the third way and this is the most important sorry I keep going back and forth um I'm antsy here I'll try to chill out okay so the third way it's ready for this the way you access information and work with information so XML this the stuff you define when you're creating your application this is all static we talked about in the previous episode how to statically define an ID for a view for any component on the screen we do that inside the the visual editor or using the XML and it's static because it's pretty much hard-coded meaning we can see the value in the code and although this works for the the start we don't want to do this all the time we want to avoid it whenever possible because it can be limiting instead we want to do things dynamically now don't take me the wrong way all of you people with 50 years of experience I am NOT saying doing things statically is bad or setting up the structure in XML is bad you should do that but anytime you want things to change or adapt or update mid app so you don't have to make a new version of your application and change it that's when things become dynamic so you can change parts of of the view dynamically inside of code and we want to make this very general or I hesitate to use the term genera but basically we want to make it so that we can make our code work in as many scenarios as possible with as little code as possible so here's an example of way we can make our code dynamic you can say our dot ID I think that's uppercase it's gonna take a little peak over here no geez our ID and then we could say an ID of an element such as hello we'll be using this as well as find view by ID and to basically grab an element and update that so later on we can have people type in what they want a textbox to say and it will update that's how you can do things like for example a shopping app or a shopping cart list or a to-do list people can type in the things they got to do press the button and it goes adds to the list it's all done dynamically in the code so none of those values are hard-coded you know you're not going to put every single possibility of things people could shop for in the application you're just going to grab whatever value comes from a text box we're gonna take that store it in what's known as a variable you could probably even skip this step but take that variable value and display it on the activity so mind the terrible drawing but you guys get the point so that's just a little bit on the history of things being static versus dynamic so thank you guys for watching please be sure to stay tuned and check in the next video because we are going to be probably making some buttons just getting some more experience with the different different things we can do so go check that out and I'll see you then peace out hey welcome back everybody in this episode we're going to do something crazy I'm gonna be teaching you how to create a butt I know it's pretty insane so here's what you do you go to the pallet and you select button exam in the comment or comment comment and you take button and you drag it and you drop it boom and that's how you create a button guys thank you for watching please be sure to subscribe and check all right I got a little bit more info feel free to stay so basically when we create this button and the reason I I felt necessary to create a video dedicated to this is because I have a little bit of extra information and when we create this button you'll first see that it automatically gives us an ID for this button so that's pretty cool if you remember from earlier episodes this hello world down here it did not default with an ID we actually had to type that out here that's important we use the ID to access this this uh view from our code so just to see this you might see something like and don't worry about we'll get into the details of this later Oh wasn't the world was that okay ID dot and then you can say hello which that's referring to that hello world but we could also say button and you can see our button automatically appears here so that's nice that's the first thing you should know the second thing and we're gonna get into the positioning stuff in detail what Claire is that you I swear Claire if you're finding some new means of communication via the internet I am going to flip all right I'm gonna mute this so we'll get into the positioning in detail later on but you can see with this hello world you can see how its kind of anchored in the middle of the screen and even if we go to a different sized phone so let's go with something larger it still positions in the middle you know it kind of thinks about it for a second and then eventually it just pops right in the middle but our button over here it's just going all over the place how do we position that so let's go back to the phone we had so we are on the pixel 3a and you can also see this over here the view is not constrained come back it only has blah blah blah so it'll jump to 0-0 so what that means is we run this thing it's gonna go pop and jump up to the top corner so here's how we fix that we're in what's known as a constraint layout and this allows us to basically define the position of this button based on the the layout that it's in so there's this little drop down here this default margin and you're just probably on 0 you go ahead and put that on 8 that's pretty good and then what you can do is you can put this button anywhere but you can take this little white circle drag it and pop to the top and that's that's where it's gonna go and do the same thing for the left and there you go so now it's anchored 8 DP what's DP I forget all right so DP density-independent pixels so it's a little bit more dynamic it's one pixel on us 160 dpi screen so that's where we're going to be using 4 for sizing so it's going to be 8 of those from the top and 8 of those from the left so what we can do is we can run this and just confirm that it works but in the meantime we can take a look on different devices so if we go to a watch you can see it's still right in the corner if we go to a TV look it's still right there in the corner so it looks like it's anchored pretty well and that's pretty good it's a little slow sometimes probably cuz I'm trying to launch this thing and it takes forever my goodness but you can run this thing and you can see our button is right there when you click it nothing happens so obviously buttons tend to do things that's what they're for so let's talk about that and that's well actually we're going to focus on dedicated in the next episode but we'll just get on the basics here one of the the attributes of this is the on click and this can be used to define some code that will execute when this button is clicked and that is going to be defined inside of this mainactivity.java so have something that looks similar to this probably down here and then we basically link the two so when we click that button it is executed and that is what is known as an event listener so that's the basics hopefully that helps you understand a little bit more of how to work with views and layouts and maybe even a little bit on the the positioning so obviously we just scratched the bare surface but I can only cover so much and I'd like to get into each one of these things in more detail as we go on so thank you guys for watching have fun placing buttons I know it's exciting and yeah let me let me see what you got let me show me your app with buttons well what can you do thank you guys and see it in in the next episode hey what's going on everybody this episode there's a couple things I wanted to talk to you about actually first thing I hope you like the red shirt I thought I'd switch it up from green and back to what we're talking about we're gonna be talking about event handling and methods all right so if you have no prior program in your experience this video might be a little bit much but I do have videos on Java methods if you want a little bit more substance a little bit more practice with that so let's first talk about method methods briefly I can't talk briefly and then we'll go back circle around and talk about event handling all right so what is a method well let's say we have I'm gonna show you what a method is by making one let's say we want some code that will toggle something and let's say we have a button and let's say we want to toggle the color like you know from green to red and then back to green well we can make a method to do that for us so a method is just a section of code that we can execute over and over and over again so it basically makes our life easier rather than taking that code and copying and pasting it every time something happens all we have to do is execute this toggle method and when you make a method it's going to look something like this public void the name of it some parentheses and then some curly braces and this is where the code goes alright so the void here if you think of a method as this black box where where I guess a white box but yeah there we go now it's a white box completely white box alright so this has some input and this potentially has some output so the in goes here the out well you did you say if there's going to be some output by by putting something here when you say void you're saying there's no output so this void here means no output meaning it's not going to like calculate something and give you back a number it's just going to do it so when you say something when you say hey toggle it's going to change it from green to red and then it's done it doesn't give you back a message saying hey the toggling was a success or it changed to green or a change to red it doesn't do anything like that it just does its task and it's done so that's what the void means it means no output all right so the input here this is what's known as parameters and we're going to talk about that a little bit more in the context okay sorry I can't talk and write at the same time parameters I can't spell we're gonna talk a little bit more about parameters in the context of event handling in the next episode and then the following episode we're gonna get hands on with the event handling so check out those two episodes so you got the basics of methods now you just gotta figure out the code to actually toggle which we'll be talking about some tricks and stuff you can do later on in the series well that's not the point of this episode we're just talking about methods here so when it comes to events what is that well let's say we have this button here okay and what do you do with buttons that's right you click them especially if they're big and red and say do not click or do not press then you definitely have to press it so you click this button now what well if we want it to actually do something we need to create an event handler which is just the method so in the attributes of this button there's a special once called on click and we can assign it the value the name of a method so for example toggle and inside of the XML it's gonna look a little something like this and again XML is not my specialty so probably something like this button and like Android colon on click and then that's going to be assigned a value toggle like so blah bunch of other stuff and the button so that's what it's gonna look like inside the XML we've seen that in the previous episodes what the XML looks like you go into into the little editor thing and then you click view the yeah you go watch the other videos so that is how you would do that and then anytime you click this button this method is going to be executed which we just showed you guys how to create that so that's going to be in the code portion for your activity so maybe it's mainactivity.java whatever it is it's going to have a dot Java extension that's where the code goes so we're gonna be doing that in the upcoming episodes but the the one thing I wanted to make sure you guys knew is that when we're doing this with on click this is real easy we just we just set the attribute to toggle or whatever we want the method to be named we define the method and we're good to go but there's other events out there that we could create event listeners for and it's a little bit more complicated on click is special you don't have to do anything too crazy you can just do it in attributes so don't worry about that for now we're going to start with on click and then later on we'll talk about some of the other events we can listen for so hopefully that was a good introduction in the next episode we're going to be talking about the the parameters or the input for this event listener that we happen to call toggle because that's actually pretty important so go check it out because you don't want to miss that one we're going to be using the information throughout probably the rest of this entire series so that one is definitely important so please make sure to subscribe and check out that next episode peace out welcome back to the world's greatest oh man my jog broke it going through this pretty quickly across what was that saying welcome back to the world's most professional Android tutorial series this episode we're going to be talking about parameters in the context of the on click event handler so that was a lot of words so oh this is the gross chalk I don't know there's like two types of chalk like this is the good kind but I mixed them in here cuz I'm stupid here this is look good here we go alright so we have something like this public we're making a method by the way void and we can name it whatever we want I'll call it toggle and we didn't really we kind of ignored to this part a little bit in the previous episode but now I want you to write out this or type it out if you're typing you I don't know what was call it V close parentheses a little closer curly brace curly brace and then you can put your code in here to do whatever you want the method to do to toggle the color toggle whether it's active or whatever now this here again is the input and the technical term for it is a parameter so we have one parameter and that one parameter is called V so the identifier or the name of this parameter is V and what exactly is this well when we have a button and we set the on click to something like toggle well what happens here is when we click it this method is executed and this button itself is assigned to this variable so when we click this button V refers to this button here now how does this work because this is a visual thing it's a button this is just a letter hmm how's that work well when we have this letter here it's actually just a name to represent an object so I don't want to go in like a hole I don't want to get off-topic too much with object oriented give you like little snippet real quick we have classes and we have objects so classes kind of defined structures there like the cookie cutters and then the objects are the actual cookies that you make so there are instances of these classes so the class here is view the object here is V so V is an instance of this view object so when we see a button like this it's actually just a visual representation of some entity in memory known as an object and we give we get a reference to it and name it V here so that means we can work with this button in code through this variable V and the variables type is a view so that's a lot of information we're going to go through a hands-on example of this in the next episode so don't quit yet not yet wait till like after next episode then you can do it alright so inside a code we can say something like V and then use dot notation so V dot and then we'll get access to a whole bunch of different things related to this button so do you remember in the visual editor all the attributes you can set on the right hand side there depending on if that's where you set it up you by default on the right hand side there well you can access these through the object reference to this button because these are this is now referring to this button here so for example we could do something like get ID and ID's drive me bonkers because you can never remember if they're okay if it's all capital or if the first letter is capital or none of its capital so I'm just gonna take a little peek and get yeah I got it right so this is is a way whether we can get the ID and then we could assign it to to an integer or use it or whatever so that's where we're getting into some of the more coding stuff whatever you want to do with that get ID the ID value you can treat it as if it's just any other integer we could also do things like modify the button so we could say V dot set enabled and we could set this to false actually this is a yeah we could pass in the value false boom now the button is like grayed out and you can't click it so if you want it to be like a one-time button like activate and then it's like grayed out and you can't click it that's how you do it I think check yeah so set enabled and then yep it takes a one-parameter or I guess in this situation it's an argument the thing you pass into a parameter when you're invoking a method this is known as an argument so it takes one argument and it's a boolean true or false so that's how we can disable that button make it no longer clickable so pretty much any of the visual stuff you would do with the button you could also do it in code and you get reference that button because it's passed in here now here's the cool thing all right let me clean up some of this junk here all right so let's say you have two buttons all right not one button but two buttons and you want both of these when you click them either one you want that specific button to be disabled well we create one method and we can set it as the onclick handler for both of them and because that parameter each time we click one excuse me each time we click one of these buttons that parameter is going to have the the value of whichever one we clicked so the first time let's say we click this one V here it's going to refer to that button so it'll be disabled because we say V dot set enabled equals set enable what false I don't want to type it I don't want to write it out so it's specific to that button because we're not we're not we're not being specific to which button is being to say we're using a general variable here that changes based on which button we click so it's not like we're saying hey the button with the ID of 12 set it to disabled that would be specific and then it would only work for one button so by being general we basically made this this method here this event handler more effective and it can work for any of the buttons so try it out go into your editor and create a method and set a parameter that looks like this view V you can name it whatever you want you can name it passed in you can name it button but just V just cuz it's kind of similar here and then just say V dot and look at all the different stuff you can do and depending on which button you click depends on which button is affected if you click this one that button is gonna be affected if you click this one that one's gonna be affected so hopefully all that information makes sense now I know it is very fluffy but that's because I like to go over the concepts face to face face to camera here so then when we go and type stuff out it actually makes sense because you're able to tie the the code to these concepts that we just covered in this video it's a more effective way of teaching and trust me I know because I'm like really good at this stuff right now I'm just playing but I believe this is the most effective way to learn you focus on the concepts first and then you go apply the the code and they'll click and it'll make sense so thank you guys for watching check out the next video to get some hands-on for this and be sure to subscribe hey guys welcome in this episode we're going to get some hands-on experience working with the on click event for buttons and let me just show you what we got so far so we got this button and if you want to see what it does let's go over to my sick new smartphone click button and look it does absolutely nothing Wow worthless well how can we make this do something well if you need a little bit more of the background information check out the previous two episodes because that's where we kind of got that foundation but if you're just looking for hey here's what your code that's what this video is for so let's get to it all right move that back over there and scroll over okay so when we click one of these button it's the same button so if you just want one you can click that so alright so we got this button and over on the right one of the common attributes is on click now you could go through and find it to the common one just kind of puts the most common ones obviously so I don't know why I'm actually showing you guys it's not that valuable but you can go on here and you can set it here now you can also search so just search on click and give it a value let's just say disabled so that's the value we give it and we close out of that so right here and you can check in the text so if you want to check out the XML scroll down and you can see we have it right here and it's complaining blah blah blah it wasn't found so basically we're saying hey we want this method to execute but it's not finding that method that's because we have encoded it yet so that makes sense so now what we need to do is we need to open mainactivity.java you can find that inside of this folder here and we're going to create a method here now what we do is we just say public void disabled so the name has to match we are in charge of this part right here we can name it whatever we want as long as this value here matches this value here that we're good then parentheses we say view V again the V you can put whatever you want there but the you need to have this spelled like this so you can't change this to something else that's not going to work so keep that as view and then you can name that whatever you like if you want to follow along exactly just name it V for simplicity and there we go now when we take this take a look at this it's still complaining maybe if we save I'm disabled let's see if we got everything I think I think everything's wired up right let's just hover over this one more time hmm yeah I think it's working it's just confused it gets it gets that way sometimes so I think we should be able to woops no exile that we should be able to run this we shouldn't get you errors what if we do we will fix those right away and literally building takes like 10 hours cannot find simple classic view okay so what does this mean we actually need to do an import so if you look up here in the code there's this import section and we actually need to add one of these so there might be a way to generate what we need from that I'm not sure but what we can do is we can say import Android dot view like so and now let's check activity underscore main not quite happy let's try dot view dot view there we go all right and if you're wondering how I knew what to type there it's just from this activity main.xml sorry I keep jumping back and forth here but you can hover over this and it'll tell you what the issue was so let me let me go change this real quick so we'll make that incorrect go back to the XML hover over this and you can see it says Android dot view dot view with a capital v they're not found so that's that's how I knew what to import alright let's go back to our code and fix that up like so now we should be able to run this app and we shouldn't get any any build issues but it's still not going to do anything because this method is going to be executed and nothing's going to happen because we don't have any code here so here is where we can run some code but just to prove it to you guys let's look take a look at our app click the button and make sure nothing happens alright nothing's happening so let's work with this parameter here remember this is the button that was passed in so the button that was clicked we can say V dot set enabled false save this will run this real quick and now what should happen is it's going to disable whatever button is passed in and since we clicked the only button on the screen that's the one that should be disabled so let this load for a second I would really think my computer is gonna explode click button and check that out it's disabled we can't click it so that's that guys thank you guys for watching and we'll get into some new in the next episode so be sure to subscribe and I'll see you then peace out hey guys welcome back this is a continuation of the previous episode but if you're just jumping in wondering how to disable a bunch of buttons and this is the video for you so essentially what I want to show in this episode is that when you create an event like this method here very simple you can reuse this event handler for numerous buttons you know you might think when you first start your first thought might be to create a new method for what each button and what happens but this is very generalized to work with numerous buttons so that's what I wanted to show you in this episode so to do that first I wanted to show you the process of creating a new button so we'll go to the design on our page and we're just going to throw a button in here and don't worry too much about the design right here I just want to get things working but just so we can kind of get on the same page we can link these together so they're always the same distance alright so they're always going to be eight DP by default so beautiful now what we do is in here on the on click we can say the same thing disabled and we can run this app and the way this works is when we click this first button this code is going to be executed and then when we click this second button right here it's going to execute that same code again so the first time it's going to go through each line of this and then it's going to stop and it's going to wait for a new event then we click the second one and it goes through each line again so let's run the app and see what happens so we click that first button disabled the second button disabled beautiful so that's how we can kind of generalize make our program a little bit more useful without having to write a bunch of code over and over and over again and that's the beauty of methods we basically extract some functionality give it a name in this case disabled and we can reuse it numerous times so that is the value proposition of using methods yeah that's pretty cool so just to show you how this works I threw together this terrible application I mean it's alright but I me and my friend put it together in like 20 minutes while we were playing call of duty so it's not amazing by any means but we're going to basically expand on this concept and try to produce a better version of this application that's a little bit more professional and doesn't look like third-grader designed it but let me run this thing I'll come on all right let me set this to false I'm sorry this you know when you're like trying to show someone something cool and it like doesn't work that's the worst all right let's run this thing and we will minimize this and we'll wait for our application to refresh over here alright so this is a very basic tic-tac-toe it's not even finished honestly we don't have any logic to decide who won because we got really involved in our Call of Duty game and it just took over so priorities right so you click a button it disables it and it gives it the value X so X is first now its O's turn o goes here it's disabled and it sets the value to o X's turn now and so forth you get how it works but there's actually no logic to determine that they won so that's probably the next thing we would implement plus make the design not look really terrible yeah but the way this works is we basically just have some variable that exists beyond the method so kind of like it's a class class level variable and that will switch from X to oh and then we just assign that to the value here and disable it so that's how that works just wanted to show you guys a little bit more on how to make your methods more useful so thank you guys be sure to subscribe and check out the next video because we're going to talk about logging which is a very useful tool for debugging and just following along with your program and all kinds of other stuff so check it out be sure to subscribe and I will see you then hello ladies and gentlemen welcome back to the greatest Android tutorial series on planet earth alright so this episode we're gonna be talking about logging it's really super simple but it's actually kind of cool because it gives you some kind of categories capabilities so basically what we're gonna be doing is the equivalent of a console log in Java or a console dot write line and c-sharp or ace whatever it's called in all these other languages basically how can we write to the console for our sake for debugging or just following along with what's going on in the application or if you know if we want to log if they we're successful or a failure or whatever it might be well it's real simple all you got to do is say log dot D and this is gonna take two arguments and you will need to import Android dot util dot log as you can see I did there so the first thing is kind of like the the category or you know what what you might categorize it as which is what I just said so we'll just say no success and then comma this is where we put a message so we can say button disabled or whatever we want to say right there now when we run this right there where exactly does this information come up well it's actually in this logcat down here in the bottom left hand corner if you're not seeing that just go up here to the windows and scroll around try to find it maybe do a search I guess I don't really know where it is right off fan so tools view and then tool windows and then log cat so that's how you find it all right now when you see this at first this is going to be an over an overabundance of information way too much and it's hard to actually see what's going on so what we can do is we can actually search for our tag right here so we will say success and I'm not seeing anything okay that means we actually need to see we need to make sure we are on the right device here cuz uh it looks like this one here was disconnected for some reason and there we go so we get button disabled I'm not sure what that's about I don't know why that one is here I only see one option up here but anyways you can search for your tag there to clean up the messages because you can see there can be quite a lot so if you want to see all of the success ones you can do that if you have other ones that say fail so you could put one on the oncreate obviously this one's kind of a lie because it actually is working just fine but what does pretend time so we will run this and now we can filter for fail and you can see it shows up right there now it did catch a couple of other things like failed to do something here and failed here so if you want to make sure that doesn't happen just make sure you give your tag name something unique enough so that it doesn't show up when you're searching for it so that's how you can do that you could say fail or you could search success and now it's only gonna show up when we select a button so there we go thank you guys for watching that's your basics of logging for Android and if you have any questions unless the question is why it's called logcat and lagdi because i have no idea so maybe you guys can help me there why is it logged en logcat thank you guys and be sure to subscribe and check out the next episode peace out hey everyone welcome in this episode I'm gonna be teaching you how to change the text on a button now we're going to be doing it when you click the button so this is our event handler for that button V refers to the the button that we clicked and we can start messing with its attributes by using the the dot operator right here so your first thought might be V dot and then something like set text and there's a couple options here set text alignment and set text or direction set tooltip text but there's nothing just set text so this is not a capability on the view class but it is on the button class so what we can actually do is we can take our object which is currently of type view and we can cast it to type button so we're going to get a new object of type button so what is that going to look like exactly well hopefully that wasn't too much of a mumbo-jumbo but just follow along button B equals and then in parentheses you're gonna say button and then the name of the variable we currently have so our variables currently named V we're casting it to a button this process is going to give us in you object of type 'button which we assign here to this variable B you could also name it button if you'd prefer that works too because this is lower case and this is upper case now when you do this you're gonna get some issues it's not gonna like it and you actually need to do an import so you say import android dot widget dot button with a capital b all right now what we can do is we can say button dot set and look at all these set texts we have so many different ones the the reason we have so many different ones is because these are known as overloads meaning we can throw in different types of data we can throw in numbers we can throw in strings or whatever so what we're going to do is we're just going to throw in a string that says disabled now I want to run this and what should happen is when we execute this we click the button and it should set that text you know if it decides to actually run but while it does that I want to show you guys something oh yeah we got an issue let's just check what is going to make it set text there we go so we set text and then we run now while this runs I did want to think of ways that we don't have to worry so much about these imports see if there's a way to automatically do it you may have saw in the previous issue in the previous video I ran into that issue and I was doing some research and it looks like you can configure it to do that automatically so you can follow for Windows I'm on Mac so I'm going to go into Android studio preferences and then editor general auto import and we'll see if we can find that so go to Android studio preferences editor general auto import and then it was change insert imports on paste value to all don't ask just do it all right there we go so now in fear we shouldn't have to worry so much about the imports but you need to make sure you set that to or you might not get all the imports I have so make sure you do that all right let's run this to see what happens we click our button it turns disabled and the text changes to disabled all right cool so that is how you do that let's just do a quick review this is an object it has the type view we cast that object to a button which gives us a new object which we assign to this variable called button we then type set text which is a method on this new object it's available to us because it's off type button we pass in the value we want and this happens when we click the button so that is all again if you're new to programming and object oriented programming and all this stuff this can be a little bit much for now what I want you to do is if you don't understand all that just type it out as is and understand that's how you change the text of things and as you get more practice doing that it'll start to make more sense and if you already understand all that I'm not trying to be annoying about it just want to make sure that everybody can follow along and be up to speed you can also check out my job of videos if you need a little bit more practice with object-oriented programming but the main thing you need to know is how to just cast this object to a different type of type button and then call set text that's all you really need to know for now you don't need to know everything so thank you guys for watching be sure to subscribe we got a lot more coming and I'm really excited so I'll see you in the next episode hey what's going on everybody in this episode we're going to be talking about find view by ID and this magical thing called R now I'm trying Orange on today so a little different let me know if it fits well I'm not really sure what color I should try next also shout out to Hobby Lobby shirts are like $3 also I'm gonna go get a haircut real quick alright that's at least a little better it's a little short I probably need this I can just write the notes on my forehead and now my shirts all itchy so I'm gonna change that as well there we go alright so what are we talking about we're gonna be talking about the our class and find view by ID so up until this point in the series we've talked about doing an event handler for a button click and when we do something like this we have a parameter in that event handler that allows us to work with that button and it looks something like this where this is the type and this is the name that we give the the view that's passed in and in that case it would be the button and this would be within a method so it would look something like this public void I'm out of space what was call X whatever it doesn't really matter what what it's named the the point here is we can work with the the view or the button in the case of the click right here by using this variable and you can get the object using that but you can also get other objects using the special method which is find view by ID now I always forget if it's find view or get view so I had to check there for a second it's fine view by ID and then you pass in an ID and we talked back earlier why IDs are so important this is why we use them to access different elements and to get an object that references that view on on the the activity page on the screen now this method takes an integer and we don't exactly have integers for the IDs of all of the different views we have on our activity so we use this special class are and what we do is we say r dot ID dot and then the string name that we assigned to a particular V view so for example we could have named it BTN for button now this here this whole thing find view by ID and then passing our ID button that is going to return a view object so we would then assign this back to a view object or in the case if it's a button we could assign it to a button like so so let's go over another example of how this could be useful let's say we have our activity and on here we have a button and we have some text what we can do is we can actually change the value of this text when we click this button using this our class so instead of getting a reference to this button here we could get a reference to this text by whatever ID we had it assigned so for example txt we no longer would be assigning to a button we'd be assigning it to a textview and we'll see this hands-on in the next episode and we'll probably change the name to something like t whatever you want to name it and then what you can do is you can say t dot set text and pass in some value so that is how you can access other elements or other views besides the one that's passed in through the parameter so this one here that refers to the button but we're able to access an a view other than the button by using this right here so hopefully these concepts make sense what we're going to do is in the next episode we're going to go through a hands-on example of this of changing elements using R so check out the next video and yeah peace out oh and don't forget to subscribe and support me on patreon hey what is going on everybody in this episode what are we gonna be doing we're gonna be talking about the art ID class and the find view by ID method now let's just take a look at what we got here if you're just jumping in you should be able to catch up real quickly we got this button here it has the ID button 11 very creative original and we have this on click which is this disabled method so let's take a look at that method real quick all it does is it sets the enabled to false so the button that we click is going to be assigned to this V this V variable we say set enabled false and then we say set text to disabled so when we run this we should be able to see this in action it only literally only two things are happening but you as we've talked about in earlier episodes you could use this method for numerous buttons and it'll work for all of them because the the button passed in depends on which one you click so you could assign disabled to the event handler for numerous buttons all right so let's take a look at our app click button and it says disabled now what I want to do in this episode is to do that same exact thing so the same result but a different way and also apologies for like the the mental pollution over here you're just gonna have to deal with that for right now so why would you want to do this a different way well right now it's not gonna offer a huge benefit because we're just doing the same thing but this way might be more versatile because it can be expanded to work with other views in your activity besides just the button passed in what if you wanted to disable all the buttons or a particular button or whatever it might be I'm gonna show you how to do that so we're gonna do is we're going to comment this junk out beautiful I don't like that that's not lined up by there we go okay that's close enough and here's what we're gonna do we're going to say find view by ID and here we have to pass in just type this out as is r dot ID dot and here you get access to a whole bunch of stuff including our view button 11 so we click that it shows up there and now this is going to return a view so it's a view object like so you're gonna sign it to a variable in this case we have to name it something different than this so we need to say something like my view or whatever you want it to be and that works fine now you can reference this variable my view dot set enabled any we could say false next thing we can do the same assignment to a button so you can say button button is equal to and then we can cast it my view and if you're so curious why we have to do that step well when we say my view dot and then we try to set the text you can see there's no option for just set text only these three options here so that's available only on a button object which is why we have to cast it so button button button my view lots of buttons it's a little redundant all right so then what we do is say my view dot set text putting some value you disable just so you guys can make sure this is the the new version and see what kind of errors we got if there are any one error fact this is one thing about this is it's not clear what the errors are which bothers me there's I can't find the easy way just to be like oh here's the error like take a look at that you always have to you guys have to run the thing and takes 30 minutes all right so cannot find symbol method set text all right oh that's because we're doing on my view which I was just saying you can't do that so we have to st. change that to button there we go so we run this now and now when we take a look at our new app once it does its refresh we click button and it says new disabled so we did it we disabled the button it does exactly the same thing with just new text but now we can do the same concept with other views inside of our activity and that's what we're gonna be showing you guys in the upcoming episodes so thank you for watching I really appreciate you guys I hope you like these videos I don't know if they're too simple too basic or if they're like too quick it's really hard for me to know because I'm creating these for so many different people so let me know how you feel about them so far and yeah also I wanna know your favorite flavor of juice so leave that in the comment section below and I will see you in the next episode what's going on everybody this episode I want to talk a little bit about casting now we have talked about casting here where we casted this view to a button so we're getting a little bit more specific but now I want to do this inside of a larger expression and just explain one of the issues that could rise and what you need to do to fix it so for example here we are taking this fine view by ID and we're assigning it to a view object now what if we know ahead of time it's going to be a button and we want to be more specific well you can assign it to a button here and it doesn't seem like that that's a problem but then you have to use this variable throughout all of it and sometimes you don't want to do that wouldn't be kind of cool if you could just do get rid of this part here and just say find view by ID pass it in and then just say set enabled false that works all right so that's one thing we can do we made that easier and there's no casting here so what am I talking about well watch this next part here when we say and and this is where I can get a little bit redundant sometimes it's better to do the variable but other times you're going to want to do it in an expression and then we want to say set text and pass in a value like so well this isn't gonna work why is this not gonna work well because set text is not available on whatever this evaluates to it evaluates to a view object this doesn't exist on that so you might think okay we just got to cast it we will cast this to a button and everyone's happy we can run this thing let's see what happens and we get an error not a statement umm what's not a statement proof it's really big for one but anyways the trick the thing is when we do a cast like this the the precedence and you can look into this more but this is lower precedence and then all this other junk on the right so what is going to do is it's going to try to evaluate all of this stuff and then it's going to try to this to a button doesn't even make sense so we actually have to do is you have to be a little bit more specific using parentheses what are we trying to cast to a button that's what we're trying to cast Oh button this is going to give us a view and we want to be specific and say it's a button so we can put parentheses around the casting and the fine view buy ad call and that'll give us a button and then on that button we can then set the text so let's try it now [Music] maybe and it worked awesome now we actually have to see if the program functions like it should so let's take a look at our program we have this button we click it and it says new new disabled which is exactly the text we put right here so that's just a little bit of a tip on casting now that is more of a Java thing over a Android development thing but it's certainly going to come up because sometimes you're not going to want to always have to assign something back to a new variable that can be good in some cases and other times you don't want to do that it's just ultimately up to you and what's easiest for you to read so thank you guys hopefully this was helpful and I'll see you in the next episode sure hey what's going on everybody this episode what are we gonna be talking about whoo you guessed it we're gonna be talking about how to get input from the user so this is going to be very important if you want to create something like a to-do list or a shopping list or pretty much anytime you want someone to type something in you need to know how to do this so pay attention I'm not repeating myself I'll probably end up repeating myself later on but we'll see so what we need to do is we need to go into our activity main.xml take a look at your palette and go into text and we'll just go with plain text so I'll drag that onto the page now I mentioned again we're not super worried about the looks right now but just so things are kind of looking pretty good you can posit you can anchor these to the left and right and the top just so it's not popped up to the top left corner so that kind of anchors everything and pretty soon we will get into more of the design or just throughout this series and honestly there's so much stuff here that I could probably do a micro series just going through all of it so that might be something you guys will see pretty soon here in the future because there's a lot of stuff like the anchoring as well as this issue here with the string we'll get into that really soon so we created this plain text and it has an ID edit text 3 I don't really like that name so I'm just going to rename it to source so basically it's the source of the data and now let's talk about how to get that so we can get that all in code within the oncreate that's going to be immediately so is that very useful mmm probably not because that's not gonna give anybody any time to write anything but let's just show you guys that real quick no I don't feel like showing you guys that that's stupid look why would I why would I say it's not a good idea and then I'll show you that that's alright what we're gonna do is we're going to create a new event handler public void I don't even know what to call it man that's the hardest part handle text and this is gonna take a view call it V whatever you want to call it and you notice that it automatically imported this for me but if if yours did not type that out I showed you guys how to enable that in earlier episode all right next up what we're gonna do is we have to think about how we get the value right here this name right now it's just name what what is uh what can we do to grab that well if you look in here it's highlighting this text field so that's that's what we want we want this text attribute so let's try and grab that in code so we'll say V alright now here's the thing how is this method going to get called well let's before we each grab the text we have to figure out how how is this going to get executed let's take a look back at our XML and I think the easiest way is probably on a button click so let's do that let's grab a button drag that right here will anchor it relative to the input field and to the left and right beautiful I mean it's not gorgeous but it's good enough now on here we can name this just button and what is it gonna do on click we will just call it handle text right there and you can see it gave us some options there which is pretty awesome all right so we got that now when we click that button this method will be executed and this V here actually refers to that button not the text so this is why we need that our ID thing so we'll say find view by ID pass an RI d dot source so that is the whole process to get the view specifically the input field now what you can do is you can say dot txt button or get text but you'll notice nothing actually shows up here because we've talked about this earlier the the view doesn't have that attribute so we need to cast it to be of whatever type this is and you can go in here and you can see that this is just plain text I think it's just text view I'm not sure how to find that I'm a terrible teacher all right text view T and we'll assign this to it so now we can say t dot get text and let's just take a look at that real quick when you type this out you should get you can hover over this and you can see that it's a char sequence so that's what it returns and we want a string so what we can do is we can say get text dot to string and then we can assign this to a string variable input like so so that's the whole process and now input should have that value so what we can do is we can just check that let's log dot D and we're going to say just tag it as info and then the actual value is going to be input all right so now what we can do is we can go into vlog cat and we're going to search for our tag their info and when we run this application we take a look over here when we click that button that method should be executed and it should log that whatever we put in here so we'll click button take a look at our log no something's that working let's try typing something in here Oh again we need to make sure wrong I think this is because I had an emulator installed earlier and I uninstalled it I'm not gnarlie sure why it's doesn't default to the the correct one but make sure you select that at that correct emulator there hey this is real time guys this is the kind of stuff you experience when you're programming I'm not gonna hide too much so you can see it actually did work we just weren't able to see it because we were on the wrong profile here so execute it put name there three times and then name FF II so anytime we put something in here we can have it show up so we can say Caleb select button and there you go button so hopefully that's helpful on how to get the text from a text input thank you guys for watching please be sure to subscribe cuz we're gonna be working with these inputs for all kinds of cool apps did want to mention one additional thing we used textview here and obviously that worked just fine earlier I went over to the XML and I was like okay what what class is this and I wasn't able to find it well actually realize if you hover over here on the componentry it'll tell you this is of type edit text so what we can do is we can go back to our java and change this from textview to to edit text and that's just a little bit more appropriate it's more specific so everything should work exactly the same way obviously if you didn't use edit text it's not gonna break anything because we tried it in it worked just fine so our app should work exactly the same way we just put something on here press button and look it shows up right there so I just wanted to give you guys a little bit extra information hopefully that just shows a little bit of how programming goes so thank you guys and I'll see you in the next episode e what's going on everybody this episode I just wanted to do something real simple I want to teach you how to take input and use it as output so in our little app here we are taking input in this plain text field and I want to output that on the screen now this isn't complicated we can pretty much do the same thing we did to basically get the value from this input but instead we're going to go the other direction so getting the value we're gonna set the value for something else so what we'll do is we will do a textview here and you can do the anchoring so we'll incur it there there and there now on the the button click I want to copy this value to this so let's give it a cool ID very creative ah now go up put and then in here when we click the button this method gets called we're getting the value from the input and we're logging it but instead of logging it I want to apply it to the output so to do that we say find view by ID and then we say re ID dot and then we put the ID which is what was the output and then set text now again it's not going to be there so we need to cast this so we'll say textview and then parentheses around the casting and the fine view by ID call and then we set a value in the set text what value we're gonna put we could manually put something here but we don't want to do that we want to dynamically set it so in order to do that we just put input no quotes so basic Java here this is a string variable so when we put it here like this it's essentially taking the value of whatever this is and plopping it right here so in theory if I did everything right it should work and it works the same way as this log where we're just putting the input value for the log it goes right here well instead of doing that we're going to put it on the screen so let's try it out so the weather alright so we'll go in here we'll put Caleb click button and look the text updates to Caleb each time we click that button it updates awesome so very simple awkward alright guys thank you for watching please be sure to check out the next video cuz we're gonna have some more exciting stuff this one's pretty easy so see you then and if you have any questions don't forget to comment start a discussion alright peace out yo what is up this episode what are we gonna be doing we're gonna be doing an alert now what is an alert whoa hey let's take check out this sweet app we got right here we basically put in some text we click this button and it shows up down here at the bottom but what if instead of having it like permanently there we just wanted to kind of like pop up for a second and then fade off into the distance it's very similar to a JavaScript alert in fact that's why I decided to say an alert so if you don't know what that is I'm gonna show you that just now and this is also a good opportunity for me to call out this imposter we have so this guy claims to be the real Caleb curry and it looks exactly like I mean he's making these videos have nothing to do with technology but I watched a couple are actually not too bad so if you want to go check out some stuff that's unrelated to programming and just have some fun here's a little plug for this guy's channel and you know maybe he'll one day he'll pass me in subscribers I mean I highly doubt it but we'll see so go check that out if you want to follow that impostor and here's we're gonna do inside of a browser you can get developer tools by right-clicking inspect and then you can click console at the top and then you just say alert and pass in some message there we go and it'll pop up and these are those things like when you go to a website and it's like wow you want a million dollars and it's like do you want to continue and the only option is like yes or okay whatever anyways we're gonna do something similar inside of Android so how do we do that it's kind of weird but we're gonna do it so we'll get rid of this log D and instead we're gonna say toast yep we're making some toast now I'm just kidding we're making some text so that's the method we want to call so uh yeah it's gonna take three things the first is the activity well we're in an activity we're on the main screen so to do that we can say this we're gonna say hey the activity we're currently on whenever we say this in the context of a class it's talking about whatever instance it's on so the instance of this main activity so yeah Java if you need more info go check on my Java series but yeah just just type this all right next up we need shoot what was it I forget so what we can do is we can we can go on a new line and we can take a look at the signature make text and look at this you can you can go through here and you can see what it expects so it takes a char sequence so let's just put in the message there I believe and then the third thing stopped going away is the duration so we will say alert and then lastly we'll say toast dot length underscore long so that's an enumeration it basically gives us a you have to choose one of numerous possibilities and then that's not it we actually have to say dot show so yeah a lot of stuff here definitely a lot easier to do in JavaScript but hey whatever let's just let's just go with what we got and we'll get rid of this line here save this and we'll execute this and now in theory when we click the button this text should pop up on our phone so let's give it a try click the button and look down here you can barely see it but it's gray it says alert right there each time we click it it pops up so you can do that one here when you want to signify something happen or maybe something asynchronously finished or you know something happens and you just want it to pop up for a second and go away but now we can actually take whatever this value is and show it up there just the same way as we've done before instead of saying alert here all we have to do is say input like so right now in theory it's going to take this value from this string right here and it's going to output it in our toast machine so why it's called toast I have no idea why is the logging thing called logcat I really don't know the world may never know all right click button it says name let's try something else here subscribe click button and obviously we have some issues here you can see it down there by the space bar so I guess it does show up and we'll work on improving that throughout the the course but for now you know a little bit of the basics you can use this for your own sake for debugging or just to check and see if things are working or to signify something that you want to fade away so thank you guys for watching hopefully I was helpful again please be sure to subscribe and go check out that phony the real Caleb curry if you want some stuff on tactical gear unboxings probably some fashion cuz you know I'm very fashionable if you guys haven't seen my my wardrobe you know life stuff basically the real me beyond the computer so go check that out peace out hey what's going on everybody welcome this is a review episode so what are we gonna be doing that's right we're gonna be talking about all these things which I wrote out because I knew I wouldn't be able to remember half of them if I didn't write them down so this is what we've talked about in the last 20 25 27 videos or whatever it is and we're not gonna go in a ton of detail of these but if there's anything on this list that's like all really confusing or you have no idea what it is then you might want to review some of the previous episodes and that's with two exceptions fragments and intents we barely talked about intents and we haven't even talked about fragments yeah I'm gonna get to that in this episode briefly so where it all began if you guys remember back in the day episode one I just talked about the basics of app development and we brought up Android app development obviously and then episode 2 we talked a little bit about Java versus Kotlin versus all these other opportunities and I decided to just talk about Java versus Kotlin in this episode these are two programming languages and they can be used to do the same exact thing inside of Android development so which you choose is ultimately up to you now Kotlin is kind of newer it's kind of like that fresh programming language on the block and it's pretty well established so it is popular it's not like it's not like you have to worry about jumping on trying it out and then it just disappears the next day it's I'd say it's more stable than the latest JavaScript framework so you can try Kotlin as well and I intend on doing Kotlin videos on this channel here too so stay tuned for that and be sure to smack that sub button we decided to go with Java since already have a Java series and once you know Java and you understand the Android principles switching the Kotlin is gonna be a piece of cake you just gotta learn some of the basics at the cotton language from what I've seen any too complicated and then picking up Android with Kotlin that's gonna be easy so that's that now the thing with apps is that there's multiple points of entry and these points of entry the different pages are known as activities so we've been working with one activity and the next section we're gonna be talkin about starting a new activity from another one so we're on the main page how do we open another page from that page and you do that with something called an intent and we're gonna get into that we briefly touched on that in an earlier episode but I just wanted to bring bring that word up so you had it registered in your little brain there yeah so that's that fragments these are kind of like yeah they're kind of like smaller activities and we're gonna probably get into these soon but we're gonna start with just getting into activities it's a more natural flow to understand activities and then move on into fragments all right so don't worry about that for now just if you are I just wanted to put that in there if you are watching this and you're like oh why didn't you talk about fragments that's because we're gonna get to them later so yeah next up we talked about layouts and also views layouts kind of group who views together so you can put views inside of these layouts and drag the layout around and all the views inside of a move the views are like the text boxes and everything like that inside of the layouts we've been using this one call to constraint layout which basically you you basically anchor different views inside of the layout we haven't gone into the detail of how to do all of that but we have anchored to the left and right into the top and that's just so if you don't do that it's always going to jump up to the top left at position zero zero so when we get into design we'll probably get into the constraint layout on how to work with it but for now just know that layouts are the the container and the views go inside of it so layouts is like a giant box and we're putting views inside of it now we can give an ID to these views so we can reference them in code and we do this by saying fine view by ID pass an r dot ID dot whatever the the ID that we assign it is so for example button or but an 11 or whatever it might be now when we have a button we can assign a click handler just in the attributes on the right-hand side of the page that's where your attributes are and this is defined in the XML so you can do that as well and it's really simple you just put the method name and then inside of the dot Java file for this activity you define that method and that becomes your event handler and when you do that you're going to have a a parameter so that looks something like this it's gonna be of type view and it's gonna have some name such as V it's the parameter and that is going to be assigned it's going to be passed in the the button that you click so you can reference that button using V so you can disable it you can change the text you can manipulate it in every single way you can manipulate a button that is another way to grab views in addition to the find find view by ID passing in this stuff so there's two different ways you can do it the the r dot ID dot button you can use that to grab any of the views this one you can only work with the the one that the event happened on such as the button that you clicked last we talked about log dot d that's how we've logged stuff to the console and then we used our toast to make little pop-ups now in the previous episode we talked about toasts but I didn't really explain that you need to make sure you have the imports and that might apply for all these things here because I made it such that when there's an import that is not there it'll automatically do it for me we talked about how to do that inside of Android studio so if you don't got that it's really easy just go to like what was it go to like system Pratt you go to like Android preferences and then you go to general and then I don't know look it up you can figure it out or watch the entire 25 videos and find where that spot was so those were the main things now what I want to do is I just want to go into either going over some code examples of some of these things just to get some review make sure you guys got it maybe some exercises or we'll just jump into the next section or we're gonna talk about creating new activities doing some more complex stuff how to pass data from activities and hopefully all these things start to piece together so that when you're assigned a task of building the next crazy app you have the tools in your tool belt to do that yeah all these things just kind of seem like random information like reference material but it's kind of like your I've explained this on my channel before it's like learning the different LEGO pieces imagine you're like a two-year-old and you see like the normal Lego piece and then the flat Lego piece and you're like wow this one can be used to make like houses and this one can be used to like 'hey i'm splain but the different shapes that's are those are these and you can start piecing them together to make bigger projects it's kind of hard to just jump in and make bigger projects without understanding these concepts so I do apologize if it's taken such a tremendous length of time just to get there's some very very rudimentary stuff but that's the approach I like to take because then I feel like you got that solid foundation and you guys can go do stuff on your own versus always happen to be stuck in a tutorial purgatory or whatever you want to call it where you you can't manage to create anything besides watching tutorials and following along use these tools to make something on your own come up with some creative ideas like I showed you guys in an earlier episode me and my friend threw together a tic-tac-toe game all we had to do was piece some of these basic things we didn't even know what half these things were called at the time we just did it because it sounded cool and when something wasn't working we just tried something else we look stuff up we got on Stack Overflow asked different questions and it kind of progressively got better you know so we just had buttons and they didn't do anything when you click them and then we got them to to go disabled and then we got him to to say Circle or X and it just got better and better from there and then we got bored and we just went back to playing call of duty and went on with our lives but you guys get the point try to do it in an exploratory manner I'm gonna stop my rant about now so thank you guys for watching and if you have any questions leave them in the comments we can try to start a discussion if you've learned anything that's been significantly helpful to you please leave in the comments because that's going to help other people who go in in the comments so if you've had any bugs and you've managed to solve them leave it in the comments and say what you did or what the issue was if you had some clarity on some concept you were confused on and you finally figured out how to put it in your brain put that in the comments because that's gonna help other people so it should be this community effort to help everybody learn so thank you and let's move on to the next episode peace out hey everybody welcome this is going to be your hands-on review of all the the primary concepts we've talked about in this series so far so if you have all those down you're a pro you know exactly what you're doing then go ahead and skip to the next episode but if you just think you could use a little bit more practice and you just want to make sure you got all those concepts before starting new stuff then this is the video for you but either way you gotta hit subscribe so even if you're a pro make sure you smack this up button and if you're not a pro then enjoy this video and then subscribe alright so where to begin well we have this activity here and I never told you this guys but you can actually resize these which is kind of cool so you can't really test the you know the dynamic Ness of your design we have really gotten to design a whole lot but just dive throw that out there so I still have my notes up on the the chalkboard so I'm gonna be peeking back there but the very first thing we did was we talked about activities and when you start you have one activity and in the upcoming section we're going to be creating new new activities and showing how to launch those so don't worry about that right yet but just know that we're we're all of the you're going to be doing is in this activity underscore main to XML for the design and that is tied to actual XML which you can see by slapping this text button down here looks a little something like this and right now it's pretty empty because we don't have a whole lot in our activity now the actual code for this is in mainactivity.java so anything with a dot Java that's where the code goes and we have some old code that we had from earlier we can go through that soon it when you start you'll just have this oncreate that's part of the activity lifecycle we'll probably get into that basically when this is created this stuff is executed alright so that's the main thing now when you're in the activity you have layouts so for example this constraint layout we could also just do like any of these layouts really and so when you have a layout you can put views inside of them so we'll go to common we can put a button in here you see how small our screen is cuz our buttons are huge alright so that doesn't look right why is it doing that okay there we go let's let's add that button in here let's try this again okay so I add this button and the button is indented from the constraint layout so that indicates that it is part of that constraint layout now you hover over this you got this red exclamation mark here and it's going to give you some some mumbo-jumbo I just clicked it it'll jump to 0 0 at runtime so when when you're looking at this and you go to the text you have this position layout editor absolute x that's just saying it's going to look in the editor like it's at this position but we can actually run the application it's going to jump up to the top left corner so if we just run this app we can show that pretty quickly and we actually have some issues because our source code has old code in it so I'm just going to comment this out for now great and now I should be able to build this and hopefully there are no other issues so again if we look at the design the is positioned here but it'll jump up to 0-0 and you can see that when this actually launches one thing I've learned while doing this series is that man this emulator slow I either need a new computer or a faster emulator you see the button is jumped up to the the top left so that's that now to fix that you can anchor it so you grab these little circles anchor it to the left anchor it to the right that'll position right in the middle and you can do it to the top as well and when you do it to the top you can see that space right there is eight you can define that right here so we could set that to 16 or whatever then if we did it again it defaults to 16 sorry about that so that is how you position but that's really not what I want to talk about what I wanted to talk about is that there's an ID and see this over in the the XML you can see ID right here and you could also see the the positioning here as well so there you go so we can use that ID throughout our code for example inside of the main activity we we can do something like find view by ID and passing our ID dot and then whatever the idea of our button is that is how we get the view in our code the other way to get our view in our code is with the click click Handler so if we are in our our design here we have the on click we can make a method to take this so we already have a method to find we'll just use that one let's take a look at what that's called it's called handle text so I'm going to copy that and paste that in d on click here so when we click this button this method will be executed and we can uncomment and now we still have to worry a little bit about the syntax because we got some stuff in here but let's just talk a little bit through this we'll get rid of these three things you can work with the the button using this V so V dot set enabled you can set that to false as an example that's the example we've been using and that's a boolean which is why it's Quotes just it's just a boolean like that you can also use this toast to make things pop up on the screen so let's say when you click the button you just want to say clicked here's how you would do something like that we can run this and while that loads we can also do the logging which i've told you guys about a couple times lock dot d and notice when you do these you're gonna have to have some imports you can see the imports I'm actively using because they're colored where these gray ones are not currently using so yeah make sure you get that copy that down and again if you want to make it do it automatically go up here in preferences let's see if I can even find it yeah editor general auto import and then should be this one right here and unambiguous imports on the fly on ambiguous meaning there's no question that it's the right one you can give this a tags such as my log whatever you want it doesn't really matter and then some message and that's gonna show up in this log cat down here so we can search for my log all right so let's run this and this will give us an opportunity to see this toast and the log D in action says review make sure you get the syntax down it is a little cumbersome won't will space this out and if you need a job I notice that spacing it like this is totally fine it's whitespace insensitive so we click the button it pops up up down here saying clicked and it fades away and then over here on our log we have this message which is this this string right here so other than that I think we've covered most of pretty much everything except we did it all in one video hmm maybe I could have just did this video and saved you guys like twenty-seven videos but yeah the YouTube algorithm I forgot yeah gotta get that watch time so just just continue watching these episodes and I think I think we'll be able to get through a lot of other cool information are building some cool stuff so hopefully this is the perfect pace for you guys maybe a little bit of experience maybe your intermediate but you don't have tons of experience and maybe my pace is a little slow but it also gives you time to really process the information and it's I don't want to make you know I don't want to make an information encyclopedia I want this to be almost a leisure to can I don't know how to word it but a leisure leisurely activity is at the way to say it I want you to be able to sit down at your desk and you know drink some coffee eat some spaghetti and watch some tutorials you know code out some stuff make some fun apps I don't want this to be like reading the Encyclopedia or like you know this isn't this isn't supposed to be too crazy so hopefully I am serving that purpose for you guys yeah and that's it so see you in the next one we're gonna start some new stuff hopefully you guys are excited and don't quit don't be a loser okay just don't not today hey what's going on you peasants in this episode we're going to be talking about activities inside of Android now I know we're pretty far in the series and we're just now getting to activities we've talked about them a little bit in the earlier episodes but now we're focusing on them for the next section of videos so hopefully we get a pretty good understanding of them now what is an activity simple question it's not those things where you like do stuff no it's not those kinds of activities it's just a screen on your app so let's say we have a phone and let's say we have the screen on the phone we're gonna go old-school we still have like a border and a button down here this here what shows up here is known as an activity and we're going to have well that looks terrible we're going to have a main activity and that's kind of like your homepage right so let's say we're in the context of an email application well what kind of stuff would be on our main activity I imagine we probably have a series of email on here from people here like so and you know I might have a little plus button to compose a new email we might have a little search and that is a magnifying glass you can tell and yeah this is an activity now when you click something such as this plus button this might open a new activity so now the screens going to change and it might look something like instead of having all these emails here you might have a a box to type in and you know your keyboard might pop up with the different letters you can type and then who you're sending it to and so forth so this is a separate activity so you can see how one activity can send to another activity another thing you need to consider is how your app is opened because oftentimes since these are so kind of like their own entities we have one activity here we have one activity here we can send people directly to a specific activity so you don't always have to go through this homepage so for an example let's say we have a website and we have an email button someone clicks that email it opens your email app and it immediately goes to the compose activity and it just skips the homepage altogether that is an example of how we can access our app in different ways and the activity that shows up depends on what we're trying to do all right so basically you can think of all the activities as serving a specific purpose and there is a level of separation of concerns so basically a fancy phrase to say the activities are not dependent on one another now does it always work that way maybe not but ideally they can be separate so it might look like something like this we can think about every possibility of different screen as an activity so we have the home page we have a compose email we have a settings we have a account details we have I don't know I'm out of ideas anyways we have a bunch of different pages and in theory you should be able to open to any one of these pages directly without having to go through any of the others but sometimes you will pass information so for example let's say you start here and you click the compose button well that's going to open this compose activity other times you might be on an email from a specific person so let's say you know we're on an email from John and we click reply well this too might go to that compose page but now it's going to send a little bit of extra information at ones and zeros that represents information it's like binary all right so we can pass that extra information so now in this activity it automatically fills in John and the the to section so that is how activities work they can they can be separate separate entities but we can tie them together and pass information from one activity to the other and the way we initiate a new activity and pass data is we're going to get into all of the the different ways of doing that how to get data from this activity to this activity and we're going to be using these things called intents yeah so we'll get into intense and what they are so we will use an intent to initiate a new activity in pass data to it but there's various ways of doing it the the passing the data part so we got a lot of information coming up hopefully you can start piecing this information together I know it's a lot of like scattered information but again we're trying to learn those Legos and eventually we'll be able to piece them together and start building cool apps but you're not gonna be able to do that unless you understand some of these concepts I want you to leave this series knowing more not necessarily just having this thing that you built and have no idea how it works so thank you guys for watching be sure to stay tuned in the next episode we are going to try to get hands-on with these activities and we're also going to getting a little bit into design how to make them not look like a giant turd and how to yeah that's that's pretty much it we're gonna get into best practices and all that stuff as well so yeah stay tuned for the next episode we'll get through the activities and then we'll move into fragments and all kinds of other cool stuff so stay tuned be sure to subscribe what's going on everybody this episode we're going to be talking about how to launch a new activity in our app and right now we're just starting off with a clean slate we don't got anything too fancy here this is the default code and then in our main activity we just have literally nothing so what are we going to do we're going to put a button here and and we'll also a anchor this to the left right and the top and I have this set for 16 DP right here now what I want this to do is we're not going to worry too much about the what the button does more that it launches an activity so you can just make something up in your head what I'm going to do is I'm gonna say that this is the settings so if you want to change the settings for something you can create a button to do that and then on click we are going to give an event handler so we'll just say launch settings and we'll copy that to make sure we have the name exactly right when we go into our main activity to deal with that so launch settings and we'll say public void and then the view passed in is going to be the button and then all we're gonna do in here is launch a new activity alright so we got the the boilerplate stuff that we need now we need to actually watch the activity so I'm gonna write out the code to do that and we're gonna use something called an intent so it's gonna look like this we're gonna say intent give it a name and notice the import up here make sure you have that and then we say new intent now if you're new to object-oriented programming new that's funny this is how we instantiate a new object of type intent and we assign it to this variable I so this is a constructor and it's going to take some arguments passed in so the first is actually what's known as a conic a context instance so without getting too much into the inheritance hierarchy of all of this our activity inherits from context so we can actually say this so when we say this we're referring to the current activity the main activity and since that is an instance of context that works alright next thing we are going to have the other activity so we can give it a name here we'll just say settings activity and then we say dot class alright so you can see it expanded this here package context yeah that looks good alright so the settings activity is what we're trying to launch we are going to need to create that so we will go over to our our project and where we have the main activity we can right click that folder and say new activity and then empty activity we'll call this settings activity and say finish and notice it says there's a layout here it's going to be activity underscore settings so we can work with that later all right so this is our new activity assuming in just a little bit all right cool and then the only other thing we have to do is inside of our main activity code we will say go to the next line here we're gonna say start activity which is a method call like so and then we pass in the intent object we just created so we say I there we go all right so I think everything is right let's just try running it and giving it a go now are our new activity we just created this activity settings to XML is currently blank so there's not gonna be much popping up but in TV we should be able to click the Settings button and then a new blank page will pop up that's the goal here so let me scroll over here ignore this this is from an earlier exercise give it about some time here man I could go for some mac and cheese all right so we click settings and look at that it opens a new page new blank page so that is how you create a new page inside of Android yeah the the code here is a little confusing like honestly I don't know the use of all of this here like why we pass us in I'm just I'm still learning all that too but this is the code to do it and then all you have to do is say start activity now if you want to design that intent just or if you want to design that activity just go to the activity underscore settings.xml which should be in your layout folder over here and you should be able to put stuff on this page as well so I'll put that there it's not anchored so it should pop up to the top but we can we can show that and that is how you would design the next page Oh mac and cheese man it's not so good right now okay we click settings and goes to our new activity and our button is there up in the top left so hopefully that helps with creating activities what we're going to do now is we're going to dissect the code for this a little bit more go into some different ways we can pass data to this new activity and we're actually going to take a little intermission to talk a little bit about design just because our our activities aren't the most pretty thing in the world we've been anchoring stuff where I'm really explain any of that so we're gonna go into that as well so stay tuned and please be sure to subscribe hey what's going on everyone this episode we're gonna talk a little bit about designing our activities now this is designed for the complete beginner so if you have some experience with design this might be a little bit of a refresher all right so let's take a look at one of our activities we have the settings activity underscore settings to XML and this is where we can design it now we do have this button on here it doesn't do literally anything so I'm just going to delete that by hitting the Delete key now so we have these we're just basically going to go over the user interface some of the key things you need to know and so forth so let's just go complete a review thousand-foot very first thing is we have these two different views we have the design the blueprint and then the the dual view so if we go to design it looks like that go to bloop blueprint it looks like that and then we can go to both now the design is going to show a little bit more of what it looks like so for example we could take a let's go with yeah let's put a button on here and then what we can do is in our constraints we could say visibility and we can say invisible we'll take a look at this it shows up on the the blueprint one but not on the design one so the blueprint one's going to give you a little bit more of a blueprint so yeah I personally just leave both up but if for some reason you just want some more space you can kind of either zoom in or you can just get rid of one of them so let's get rid of that button when I couldn't need that for right now but that's the first thing I wonder show you guys next you can change the orientation of the device another thing is you you can choose the size of the device right here or what phone you're working with but you can alternatively take a corner maybe if it's gonna let me know there it is there's a little thing here you can drag this up and it'll tell you about which is a which size goes where and that way you can do a completely custom size and that's going to resize everything you could do that if you want to test for you know dynamic Ness test to see if it's responsive for different screen sizes so that is very very useful now you can see it says custom here so we're no longer on a specific one we're on custom so you can always go back if you want you can select one of these like so now the next thing I wanted to show you guys is the component tree so this is basically a structural representation of how our activity is laid out right now we have one layout and a layout is basically a collection of different views which we can grab from over here so for example we can grab a textview we can grab a button and you can see as I've explained in earlier episodes these are indented a little bit because they are inside inside of that constraint layout so we can select the entire constraint layout and that's going to contain those two things inside of them so why is this important exactly well you can think of it as putting these inside of the box so when you have the box you can move the box and everything inside of the box moves with it so if we are working with some other will go into layouts and just add another constraint layout here we can drag this one around but if we put some stuff inside of it such as this button well that gets that remains in that position relative to its parent which is the constraint layout right here now you will notice you get some errors here and we're going to be talking about those so don't worry about those for right this second we'll get into the anchoring as well as the if you have a string on here it will complain something so for example this text view it should complain about that as well so watch us I mean anchor this real quick you'll get this little exclamation marks and it should use a string resource we're gonna be talking about that as soon as well so don't worry about that for right now let's clean up our page just get rid of that constraint layout and you can see everything inside of it also goes away so that's important to know now with the constraint layout that is a layout that basically positions stuff based on constraints which is how things are connected to either the parent or other views so when we put in a textview it looks like it's in the middle here but it's actually going to jump up to the top left corner which is why it says it's going to jump up to zero zero right there so to fix that we need to anchor it on the left and we need to anchor it on the top you could also do the right or bottom but you have to do one either on the left or right and you have to do one either on the top or bottom so that way it knows where to position it now if you zoom in here a little bit you can notice that there's some space here and that space is determined by this right here so right now it's a 16 DP and that's the default spacing so if you want more default spacing for example always keep going away stop it alright let's try this we'll try 100 now as I'm gonna change what's already there those have already been established but if we go add a new button in here and we anchor it look it it defaults to 100 there so that's useful so that is one way you can anchor you can anchor to the edges of the the parent container but you can also anchor based on another view so for example you can lock this position here and now it's going to always be 100 DP from this text view that's the alternative way of positioning stuff if you want things to be relative to the other views inside now all of this gets translated to XML and you can see that inside this text tab here look at this great yeah it's kind of boring now what I want to do is I want to get rid of these constraints here get rid of them here and get rid of them here now when you look in the text you got this button you can see it says layout editor absolute X that just says where it's positioned in the editor when you actually anchor the thing it's going to show up differently so we enter it and now you can see layout margins margin top 100 DP and we have this constraint top to top of parent so thankfully we don't have to write this stuff cuz I would be a huge pain so that's the basics of designing obviously it's not I'm not teaching you guys how to make it pretty that's either going to be for another series or for you to experiment with what I'm trying to do is teach you the functionality here and how everything works there's all kinds of different of views you can use from the palette so give some of them a try drag them on here and see how they show up and learn how to oh it doesn't like that okay that's alright well fragments that's a whole nother beast what we're gonna talk about those later fragments is basically where you can put a it's kind of like a miniature a miniature activity that you can put inside of your other activities and you can reuse them and so forth so that's the basics hopefully it was helpful let me know in the comments if it was or if you'd like more of this stuff let's go into the next episodes we're going to get into some more cool things so thank you guys for watching be sure to subscribe and all hopefully I gave you enough information to actually position stuff where you want them alright bye hey everybody this episode we're gonna be talking about this little issue you get when you're working with it a text view it says something stupid like hard-coded string text view should use a string resource so what in the world is this and why am I getting this morning now by the way this is a warning so you can execute the code just fine now it's kind of unrelated I'm sorry guys but if you take this and you get rid of these bankers I think so hey well you're gonna get this this error here but it actually still executes just it's going to reposition at runtime so I don't even know what I'm saying with that let's go back to what we had alright so I was just basically saying that these are not mandatory to solve but they are highly recommended all right so when you're working with a really simple application it doesn't really matter you can just go in here you can go in here and put some text and say something cool like horse and that shows up and it's pretty and you know you can do all kinds of anchoring stuff and you can make your pretty user interface and press your friends go in here and make it like cool yeah so that's your button and okay not a button sorry that's your textview well we're getting this warning and basically whenever you have your text you want to try to avoid hard coding text so this is hard coding because we're typing it in and if you look at the XML take a look at this horse right there we don't want to do that whenever we can for simple applications it doesn't really matter because if we want to change it we just go in here and change it no problem but as we get larger applications we might want to basically change the text throughout the application so it depends on it depends on how soon you feel it necessary to do this it might just be best to do this from the very beginning and I think that is what most guides are going to recommend so instead of saying horse here we could basically obtain the value of what should go here from another resource so basically we're going to separate out all of our strings to another resource now where is that resource well if you take a look at your project here and you got your layout here just go down a little bit more and into the values folder strings.xml double click that open it up take a look and basically we got a key and then we have a value so we can go in here and we can manually edit this or what we could do is we can click open editor and it says edit translations and for all Ocala blah blah so this is also really good and recommended for translation use so basically you can swap out the strings for a different language very easily so what we're gonna do is we're going to click this little plus button give it a key so we'll say I don't know my string now it looks like we want to go with this yeah underscore default value is going to say horse all right so now we could use this my string instead of horse directly and then we can go in here and change this value and it will propagate changing any reference to it so let's take a look at our activity got a little bit much going on here so we were in the yeah we were in this activity settings to XML go back to the design get rid of this text here and now select this little box thing which doesn't look like it's anything there and we can go in here and we can find our our text which was called my string and it has the value horse click OK Hey look it renders the value horse but we go into the text and there's no reference to horse all it says is my string so now check this out we can go in here we can create a button and we're gonna change this text get rid of this and we'll say the same thing my string so now I have two references to this and what we're going to do is we're gonna go change that value so we'll go to string aside XML and then we're going to take my string and change it to pig all right now taking a look back at our thing both of these change to the value pig awesome so that is what that error means and how to fix it thank you guys for watching be sure to stay tuned because we got lots of new content coming for you alright then everyone welcome in this episode I'm going to be teaching you how to change which activity is your main activity the one that is displayed when you open the app using the icon on the home page of your phone so let's take a look at our phone here so if you want to get to the home page you can slap this little circle down here and you can actually hold it down and swipe up and you can see all these different apps in here and you can see a couple of these have the default icon so those are the apps I've been tinkering with and ours is actually right here my application and it goes to this activity the main activity you can see the looks of it right here well I have this other activity I created the settings activity and we can take a look at that we can take a look at the XML you can go to the design view and honestly just I want to clean it up cause it's weird alright let's get rid of that stuff and just have a blank activity so what if we want this one to show up well we have this magical file the Android manifest and this basically describes a lot about your application and the activities that are inside your application and as a stupid yellow highlighting is annoying but anyways the thing we want to find in here is you can see we have our application it opens here and closes here then inside here we have two activities so this is one and this is another you can maybe minimize that to see it a little better so this is the settings activity and then this is the main activity so ignoring the name there for a second we have this category and it says launcher and then we have this other action here that says main and these are the two things that determine which one comes first so if we cut all this and we actually put it inside of this other one here paste that there save this and we're going to run it in theory theoretically maybe it'll open up to that new settings page so let's take a look at our app make sure refreshed and everything well we'll go to the home page swipe up we got my application click that and there we go we're on the settings page there's nothing here because it's an empty activity so that is how you determine which activity is going to be opened up from the home page now later on I'd like to get into this a little bit more because there's more useful stuff in here so for example this determines the icon you can see that there and you can find it down here we have this icy underscore launch or folder and you can find our little icon there so we can manipulate this these files and this Android manifest to basically customize the application and make it our own yeah so that's the basics we're going to go into a lot more or so from one Tiger well the icon and the theme and how to brand our application we will get into that later on after we discuss activities for now we're sticking to the fundamentals so I'll see you guys in the next episode hopefully it was helpful I think it was pretty probably pretty helpful hey yo what's up this video we're gonna be talking about how to change the title of your activity so this is what's gonna show up at the top of your application when you're running it and it could be different for each activity now in the previous episode I told you how to change the main activity I just want to let you know I changed that back if you're following along so when we've launched this application it's just going to launch our default main activity now there's a couple things you got to watch out for on this alright so the easiest way to do this is to just give it a label so let's say we want to change our settings act 8 activity and we'll just have to preface this with Android gives us a value such as settings so before I launch this lets show you what I got so far our thing just says my application and I'm currently on the settings activity there's nothing on here but this is what it says I want that to say settings so I say Android : label settings and I'm inside of the Android manifest and we're inside of the activity thing it's just an attribute in here so we put a space after this attribute and I put another attribute so similar to HTML so let's run this and we'll see how that works and while that loads we can do the same thing for this activity here we'll say I've got perfect set again Android label and we'll say home all right cool okay so scrolling over we'll go to my application and it says settings so we click settings and it says settings awesome so going back it still says my application because the the current change to home we haven't actually ran that yet so before I run this I want to show you something and this is the Gotcha eyes weren't warning you about when we change that label on the the main activity we actually are gonna change the the title of our app so if we swipe up on here says my application right there watch when I change this label to home so I'm gonna run this now it's actually going to change the name of the application to home so if you are working with the activity the main activity and you want to change that label there's another way you can do it that I'm going to show you and that that's that'll fix the problem so let's take a look at this it says home at the top so that works but when we take a look at our apps you can see it says home which is not what we want so let's not do that we're just going to label this and learn Android and we can actually change the the name of the activity the title of it inside of the Java on the oncreate we can say set title pass in a value of home now we can run this and we'll just check to make sure everything works as expected so we open the app excuse me and it says home right here so that's good close this swipe up on and see the apps and you can see it says learn Android it's a little long so it's getting cut but it seems to be working so that is how you rename your activities and we showed you how to do it in the XML and we also showed you how to do it inside of the decode so when you're working with whatever activity is your main activity so in this situation we have this one Li what is the main here we we want to do that not in the XML because that's going to change the app name so you want to do that inside of the code thank you guys for watching and I'll see you in the next episode hey what's going on everybody in this episode I'm gonna be teaching you how to do backwards navigation from an activity so to illustrate this let's take a look at my app so we have this button it goes to settings which really just empty it doesn't do anything but you can see there's this arrow here and that'll bring us back to the home page it's actually really simple to set up and you can think about this as this home page being the parent and when you click the Settings this is a child activity and then we just say hey we want to label this as the parent and then the arrow just automatically appears so it's actually really simple and the way you do this is you go into your Android manifest inside of app manifests and we'll scroll in here just a little bit and we have the the main activity and that is defined as the main using this this intent filter the previous episode I taught you how to change which one was the easy starting activity well we changed it back to this main activity and we want to set that as the parent so we actually go into the settings activity and we added a new label here and we say Android and I'm gonna bring this down to a new line so we can see it nice Android colon parent activity name and set that equal to dot main activity so I did that once and compiled it which is why it worked but if you're following along and you create an activity that arrows not going to be there by default unless you set the main activity as the parent using this attribute right here alright so what you can do is you can run it and I'll prove to you that it works because it's going to be exactly the same as we have it so our app will launch we click settings and then there's the arrow there so nice and simple that's how you do that guys thank you for watching stay tuned for the next episode and please be sure to subscribe hey there what is going on in this episode I want to be teaching you how to pass data from one activity to the next activity so obviously you can use this if you need to connect to activities or you need to change the way an activity acts based on the data passed in so we're going to break this down to the simplest components and just work with two very simple activities we have the the starting activity the main activity with a button which opens another blank activity if you want to see this in action check out the sick app right here click settings and boom it pops up right here we've built this throughout this series so I hope you have some experience with at least launching an activity but I'll show you the code that you'll see that code in this episode as well so let's go back to the home page here and let's take a look at our code so we have the the XML here but now in the code we just have this launch settings which is the the event handler for when you click that button and we have two code to launch our other activity which is right there yeah so we can actually attach stuff to this intent so it kind of acts as this I don't really know good illustration but the suitcase that we can put stuff in and then hand the suitcase off to the the new activity and then that new activity can open the suitcase and get all the goodies inside so before we start that activity we can add data to to this a fancy suitcase by saying I dot put extras and then we pass in an ID so we'll just say cool and this would be a string and then we'll put a comma and then our actual message which will be like hello and I think we actually want to use put extra here so there we go all right so you could use put extras if you say I dot put extra you can look through all the the different options here the different overloads if you put extras it actually takes a bunch of extra information so we'll get into that later on so we'll use put extra to pass one piece of data we give it a key and then we give it a value so that is how we identify the string if we want to grab this one we use the key cool so yeah very realistic example here as you guys can tell so what we're going to do now is we're going to go over into the activity that we're starting the settings activity so we'll open that zoom in a little bit and inside of the oncreate we can grab access to that data so all we have to do is say intent I equals get intent that's going to take the suitcase and then we could say I get string extra and then we pass in the key which was cool alright so then this is going to return that string so we actually have to do something with it we can just assign to a string we'll just say string message and assign it this right here all right so this message will now contain the value hello which is the value associated with that key there so if you if you want to see that we could put an A a view on the activity to display it so let's try that we will go into the XML for this so activity settings and we're going to drag in a a textview we'll just plop it right here and we'll just Center it in the very middle of our application like so and then this is gonna have an ID of just textview so inside of our java code we can say fine view by ID our ID dot textview and then we could say dot set text and to get this to work we have to cast this to a textview so we'll say type of textview and we need to put parentheses around all of that before we put the the dot here set text now we should be able to put in a value and we'll put in that message like so all right it doesn't look like we have any errors but you know it's there's a high chance we do so we'll just we'll just run it and see if everything works all right so run this app and right now we're just using the hard-coded value so taking a look at me at main activity you can see we're just using this hard-coded value but you could also get this value from one of the views on the main activity and we'll show you guys that as well so let this cycle here it just finished it's gonna refresh and we should be able to check to see if it works all right so we hit settings and it says hello wow it actually worked so we did everything right now I want to get this message from another view so we're gonna do is we are going to go into the main activity XML and we're going to put in a let's go to text and I'll just use plain text here sure we'll just put it let's put it above the settings so we'll put name up here anchor that to the top sorry I my computer's a little slow here all right anchor these to the side and then we'll anchor settings to name right here beautiful this is going to have an ID of edit text so we will get a reference to that will say string message is equal to fine view by ID our ID edit text dot get text and now again we're gonna have to do that weird casting thing so we'll just say this is a I off for some reason I always forget the the the class name so this is an edit text alright so edit text and then we'll put the entire call in parentheses like so and then instead of passing hello we just pass in message so let's run this now just while that okay we got we got an issue can our resolve method what Oh string is capitalized so we have to make sure that is the right type and then we have to say to string sorry there's a lot here so we we get the view then we get the text of it and that's not quite string type so I have to say to string in order for us to store it in a string variable and then we pass it in here so that should be everything and while that loads let me just go through this all we get the message we add it to the suitcase using put extra we assign a key of cool or a name whatever you wanna call it and then we start the activity and then in the other activity the settings activity we get that intent we take the suitcase and we open the suitcase and get the message with the name cool we assign it to a variable message and we set that to the text of a view on this activity's screen so it's a lot going on here but let's try it out we'll type in we'll just go with Caleb very creative settings and it says Caleb now obviously the button saying settings is a little silly like why would you need to pass data from this to the next activity it's just it's just an example another example is you might be making an email application and you might hit reply and the data you pass might be the the person you're sending the email to their email address so that just automatically fills the the two field that's another more useful example but uh yeah this can be applied to lots of different things so thank you guys hopefully that was helpful it is a lot just to do that very simple thing but hopefully you can you can build upon this to create really awesome applications and make millions of dollars yeah what is going on so this whole series we've been talking about how to create stuff inside of Android studio this video is special because we're gonna be talking about how to destroy stuff I usually don't do this stuff because usually it's pretty simple to figure out but just if if you need a little bit of assistance we're gonna be talking about how to remove an activity from Android studio and just be sure that we get all of the this stuff floating around that references it so why exactly well because I have this settings activity and I decided I want to destroy it I want to instead create a contact activity so you have two options one you can rename stuff and change references and make sure everything could be changed to this new contact activity or you could just delete the settings activity and start fresh I generally prefer starting fresh if things are pretty easy to get started and creating a new activity of this complexity is really not going to be really too difficult so what are we going to do well if you see we have the settings activity over here in the Java folder you can right-click this and you can find find usages and this is going to show where this activity is referenced in your code so you can see it is referenced inside of the main activity inside of a method so what we can do is we can basically go through these references and you can double click it the the most expanded one will show up here and this will reference that activity so you can change this code here so get rid of that you could also get rid of this method altogether if if you want this event handler to not do anything so we'll get rid of that that was a button handler on the main activity so that's one thing and now you can see it says invalid down here so that's cool so now next up we have in the layout let's double click this this is in the settings activity XML and it references it inside of here but we're actually not going to need this XML file at all so we can do is we can just delete that and that's going to be right here so we're going to right-click this and delete delete' that the other usage is not expanded right here double click this and this is inside the Android manifest so there's this activity reference right here and that refers to settings activity make sure you're not deleting the main activity you can check to where see where it ends by looking for the forward slash and then the greater than sign or you might also see something like this here and then a closing tag like this in this situation you would close the entire section so do that there so that gets rid of the reference in the Android manifest which is basically the file that keeps track of all of your activities so then at this point you should be good to go into the actual Java file the settings activity and delete this all right and lastly you might see some reference to this inside of this values folder which is inside of this res so go into the values and open strings you might see a reference here so you could delete it there so for example we have this main two activity one here but it I'm not seeing one for the settings activity so we're fine we don't have to delete anything so to conclude what all did we do we do we did it from the Android manifest we deleted the Java file and we deleted the XML file and we deleted any code referencing the activity specifically we had some code that that initialized that activity so we got rid of that and optionally or in this case it wasn't required but you could go into the strings and make sure there's nothing here as well so pretty simple video but just thought I would cover that because if you've been following along I don't want to jump and into the next episode and we have a completely different set up and I didn't explain anything on how to get there so now you know how to delete an activity pretty simple so stay tuned for the next episode because we're gonna start creating again see you then hello everybody welcome back in this episode we are going to start fresh so in the previous episode we talked about how to delete different activities and do all this different stuff but now I just I just want to start a new project I want to talk about something new so to do this you go to file new project and what I want to do is I want to show you guys that we can actually very easily create a tab system by using this bottom navigation activity so if you're looking for a way to basically scaffold out an application without having to do a whole lot or generate an application you can do that this way just by clicking one of these these different options so we'll click Next and we'll give this a name call a YouTube and we're going to use Java and now for the API you can choose a newer API if you want some of the the new the newer stuff but I would say API 19 is fine that's gonna cover 95% of devices and we're not going to be using too too much of the the new API stuff so for now we'll go with 19 but you might want to go with a higher version so that's up to you so then we'll click finish and you can just say goodbye to our old application yay that's the easiest way to clean up a project is just get rid of it alright so now I got this new application and what I want to do is well first let's open the the project and we'll go into the app under the source and then to main and then the Chava man there so come on really why are you doing this to me all right going to that's better all right so we'll go into Java and then the main activity which opened automatically my computer's just so slow that it just uh took a couple of patient minutes there all right so this is the XML and we're in the text so we can go to the design tab here to see what it looks like and it's looking pretty good you can see we have a home a dashboard and notifications so we already built out this really cool application and we didn't even have to do anything and you'll notice a ton of the apps on the App Store have this similar style they'll just have some buttons at the bottom I'm guessing a lot of the developers or are just setting up this default app charging tons of money for quote custom apps and then they just change a couple of things and boom they have a new application but in reality they're just using one of the the default options so let's run this thing and just see if it if it looks anything like this if it looks pretty good we can also look in here and see how it scales by dragging this here and it seems to be very dynamic we can also check the switch the orientation here we go landscape mode and see how it looks there yeah so this is a very common style let's take a look oh that's our old application showing an X out of that let's take a look at the app and see how it looks give it about I don't know 30 hours it's working its way up oh okay this is the home fragment are awesome so this is using fragments and we're going to get into that soon we've been talking about activities up to this point and activities are essentially the the entire page but it looks like each one of these tabs shows a new fragment which you can kind of think of as a a fragment of an activity or a piece of an activity that you can reuse so maybe this part of the screen is a fragment and if you want to see what this looks like in the visual editor you can go over here and you can see inside of the component tree we have this nav host fragment which takes up this portion of the screen whatever's inside of the the blue there so cool when you can see those fragments over in the in the layout so we have the fragment dashboard the fragment home and the fragment notifications and you can go inside of these to see what they look like which in this case they really don't have anything at all so yeah but we'll get into all the fragments and stuff pretty soon I just wanted to show you guys how to create a tabbed system and yeah that that's pretty much it so the next episode we're going to start working with this application and building some stuff out and we're gonna continue our discussion on activities and passing data between them but pretty soon we'll transition into fragments because we need to learn about those as well so thanks stay tuned and be sure to subscribe what's going on everyone in this episode we're going to be talking about some of these different options on this text category of the palette now you can just get in any activity there's no prerequisite content you just drag some stuff to the screen and start playing around with it I do have here a plain text that I dragged to the screen or drug however you would say that I don't know and it's cool it works it does its job but one of the things I wanted was to be able to type and it would go down to the next line as if you're writing a larger message or an email or something and actually found there's this option here multi-line text so you can drag that to the screen you can anchor that real quick and it seems to do the trick pretty well but is there really anything diff between these two because if you look down here on the component tree you can see that they're actually both of type edit text so what is going on here why do we have all these options if they're both edit text and how do you differentiate the two well it actually comes down to this input type attribute and you can see there's a bunch of different options on here one of which is this in this case we just have this text person name here which when you check that it checks text and text email address and text short match message so in other words we can combine various selections here to customize the input so let's take a look at this one when we go to this one and we go to input type we have text multi-line so that allows it to work across multiple lines so the difference between a lot of these text options on this palette is that we just have different customizations for the the type for the input type now this isn't the case for everything for example we have one of these is the the multi autocomplete text view as well as the autocomplete text view so we can drag one of these to the screen and I will anchor this to the bottom cool now let's run this and just just take a look at what we get and you can see over here on the left the autocomplete text view is actually a different type so that is not just a customization of the the plain text is it's the own entity so taking a look at our application we can try out these new ways of typing so this one we can type in some stuff here and look at that it goes down the next line that's different than this one where it just Scrolls forever so if you want to get rid of the keyboard you can hit this little arrow down here at the bottom and then we have the autocomplete text view which works pretty much the same exact way so you can put stuff in here and you can fill up fill up the page now this one also does that though because I can go in here and in Auto fill this so I'm not entirely sure the value of this autocomplete textview because it seems that this one does it by default and maybe that's something that's dependent on the the android operating system or the phone you're on I'm not entirely sure but just so you know that is a thing that exists so those are some of the different things you can do to customize the the text inputs so when we want to create a way to create a message what you can do is you can go format this thing to fill up more of the screen and then it'll scroll down to the next line and my only request for you guys is I want you to autofill one of these things and I want you to copy and paste the message as a comment just to see the the wild things that pop up and make sure you don't put any contacts just post it in there that way YouTube looks at it and it's like the algorithms totally confused with the conversations going on in the comment section so that'll be fun so do that and start playing around with some of these different options in the palette and look through the different options in the input type for example there's password so it looks like there's a search which is nice password didn't show up so let's let's see what password has elected if we drag password in here it is okay text password so yeah but that's how you do that so if you want the password you can select that one and there's all kinds of other options on here so you can get exactly what you need so I know it's kind of simple but just wanted to share that with you guys and check out the next episode see ya hello everyone in this episode we're going to get a little bit more practice with activities passing data between them and making them dynamic now we're gonna start fresh with a new project so okay I'll open Android studio and start a new Android studio project and we're just gonna go with an empty activity and we're gonna call this whatever you want we'll just call it like activity practice and we're gonna go with Java but I mean if you're using Collin by all means whatever okay it looks like I already have an activity practice so is named activity practice too but you're just probably just activity practice and that's fine so what we're gonna do is we're basically going to make an activity that is separate from remember like the whole idea is keep things separate so we have the main activity which is like the home page and then we have a new activity which X has its own module sort of so we just passed data to it and it will work so imagine if you're working with an email application you compose an email and that'll work if you reply to John if you reply to Sally or you reply to someone else and you don't have to have a new activity for each one of those options you just have one and then you kind of generalize it so that you can take input such as who you're sending the email to so that's just kind of like a silly example but we're going to basically try to produce that same concept here right now so if you wanted to have a list of emails you could really easily do that with a recycle a recycler view and you can get that by clicking the little arrow there but it's not quite as simple as just dragging and dropping and then boom you're done there's a little bit more work to it so we're gonna save that for another episode because that's really not the focus of this episode and that'll take some time to set up and explain so we're gonna keep it simple we're just going to work with some buttons so we'll drag a couple buttons in here and we'll zoom in here and you can lock these to the left and to the top just so they're not just all in one spot again I'm not working on design here I'm just trying to get some functionality going so what are these buttons representing well imagine we have a list of emails and we have the option to reply to the first one reply to the second one reply to the third one and so forth so each one is like a reply now you can generalize this a little bit and think hey this might work for an application where you can respond to support tickets or respond to instant messages it doesn't have to be email it's just that concept here so if you remember from an earlier episode we have this on click Handler so click one of these buttons and we have this on click we can just say something like compose message and we're going to create that method because you can see it's red now it doesn't like that so we're gonna go into the mainactivity.java and we're going to create that method so we'll say public avoid compose message and it can take the argument which is the button that you clicked so that's of type view V is the name alright so also I'm stupid and I put this in the wrong spot so make sure this goes inside of the class there beautiful alright so here is where we would handle that button click and we can actually set that to the on click for all of these and we're going to make sure that this works so just yeah it looks like it's it's working so we'll do that for all of these go to the on click and compose message so regardless of which button we click it's going to work so now we can change the text on these we'll say the first one is reply to John this one is someone else I feel like that's a better spelling there we go so reply to John reply to Sally reply to Amy now regardless of which one you click you want to do the same thing you just want to be a little bit different so let's create that new activity and to do that you go into where your main activity is right click that folder and say new activity and we're gonna go with an empty activity and we'll just call this compose message activity and that will generate the the file here as well as the XML which will be named activity underscore compose underscore message XML and it looks exactly like the one we had but now we have to put a little bit of stuff on here as well so we will start with a text view which is just going to basically imagine this being who we're sending the message to so that's what we're going to dynamically change and then we're going to actually have a a multi-line text here so we'll go play multi-line text drag that in here anchor this here and to the left and then lastly we can have a send button so we might want to give this a little bit more space so you can drag down the corner here and then we can have a button which will just put below it looking good oh yeah man very nice okay so what we can do is we can run this just to confirm that the buttons are working and that it's launching this new activity and then we can start working with the data to change what shows up here and so forth so give this some time to run and we will check out the application make sure everything is working throw this in full screen and scroll over all right so we're applied to John kind of an important part I forgot duh we need to actually synchronize that when you click we we launch this new activity I don't know how I managed to forget that but in the compose message we have to start with an intent which is how you launch a new activity so we'll call it I and say new intent it's gonna take two arguments the first one is going to be this so the instance of the main activity and then compose message activity dot class next we're going to say start activity and we're going to pass in I the intent so that should make it launch the new activity we're not doing any data passing but at least it should actually do something so we'll let this refresh click those buttons and make sure I'm not being stupid this time so click that button and it works if you want to go back you can click the little arrow here to go back awesome and you see all three of them work so we are we are in business now now we have to talk about how to actually pass data between the two so what are we going to do we're going to get the the person's name so we'll create a string and then what we're going to do is we're going to take that name and we're going to pass it with the activity or with the intent so we'll say I dot put extra will give this the name name comma and then the actual value which is going to be stored in this variable here so now we have to get this value and to do this we just say V duck get text this isn't an option on this on this object so we actually need to cast this to and edit text instead of just a view and then pass this whole thing in parentheses before the dot there we go so that is how we get the name great now we can access that inside of the other activity so let's go over here to compose message activity and inside of here we can say get intent that's going to return an intent so was assign it to a variable called I and I will say string name is equal to I doc guess string extra and pass in that key which is name so now we should get whatever that name is here and now what we can do is we can dynamically update this value here so to say that we're sending a message to whoever it might be so let's do that let's get that thing's ID we'll go into the back - yeah the activity main here no sorry this one I'm grab that textview so the ID is just text to you and we need to set the text attribute so we'll go in here and we will say find view by ID card ID text view set text same thing here we just need to do the casting so we'll cast this to a text view and then put everything in parenthesis before the dot for the set text what are we going to set it to we're gonna set it to name alright we're not getting errors on this page so that all looks good but in the mainactivity.java it looks like we have an error so let's take a look and see what is going on I'm not seeing anything so maybe it's just uh maybe it's just a little confused let's run this and see if it compiles okay cannot find symbol class edit text okay yeah that's just because we need to capitalize it the class name is has a capital so let's run this now editable cannot be converted to a string okay so to fix that all you have to do is say to string pretty simple run that now let's give this a try so we reply to John and it crashes oh yeah all right let's go into the run see you what happened here not getting anything so let's let's just try this again see you see what's going on reply to John weird alright here we get an exception so we can look at it could not execute method for Android on click so the actual problem is fairly simple I am doing an incorrect cast here work we're making it in edit text but it's actually a button so we just need to convert this to a button instead all right let's go over to the app or apply to John and there we go reply to John shows up here we can type in our message and then we can turn this button into a submit button and send that message off somewhere else so that is the basics of working with activities the beautiful thing here though is that this compose message activity will allow us to send a message to any of these people I mean in theory it doesn't actually work right now but you know we could make this functionality work by programming this button right here which would be very similar to how you would do it with clicking these buttons you just create a method for the on click event and so forth so there you go guys that's little bit more practice working with activities hopefully that was helpful for you and be sure to stay tuned in the next episode because there's actually a potential issue with our with our application that we're gonna try and fix so thank you guys I'll see you in the next one hey everyone it is a new day here I'm getting a bright and early start here on the tutorials for the day and let me just tell you guys I'm a little salty because I posted a video and shared it with you guys on social media and I immediately got like three dislikes guys are in grateful alright here's what you know I'm still gonna produce amazing content for the few of you out there that really care so what are we gonna be doing today we're gonna be talking about dealing with nulls in the context of a new activity so first video of the day might be a little rusty but I think I got this alright so here we have an intent and part of this intent is the the data that we pass to it so if we take a look at our our main activity right here what we do is we say I put extra so we attached this name to the intent so I gave the illustration in previous episode the the intent is kind of like the suitcase we pass along to the new activity and inside of that suitcase we have one thing with the name name and the value which comes from the value of this button here which I can show you that guys but some of the problems here is that sometimes you'll pass something to an activity and sometimes you won't so what are you supposed to do when it's null how do you deal with that but just so you guys can see what this looks like we have this reply to John we click it and it says reply to John now there's button down here I actually added that so if you've been following along don't worry about that all right but watch this let's say instead of assigning this to name we we just comment this out let's say we don't pass that in now when we run this what's going to happen because inside of our compose message activity we are getting that value here so this is going to be null so yeah that's bad we don't want to do that but we're gonna see what happens so we were applied to John and it's empty now I'm going to set a breakpoint here so we can just confirm this so what I'm gonna do is I'm going to hit this little bug button up here and the way this will work is it'll run to this point when we click that button so over here we have to click that button and that breakpoint will be hit so reply to June this is hit check out the value of name its evaluating and its null so it's not the value null it's not a strip it's not a quoted word null null actually means no value so when we're sending the text here we're setting the text to null we're not getting an exception so that's interesting it just it works but we're not actually showing any value there sometimes we're going to want to do things conditionally though so I'm going to be teaching you guys how to check for nulls so very first thing we do is we say if and we can put the value in the the expression here and I'm gonna stop debugging so we say if name is null this is a key word here that's how you check then we can do something so we would say let's say we'll if it's null we're gonna do something otherwise we're going to display the value so we'll take this cut it and paste it right here so if it's null we could put something else so let's just say well we'll just say composing message so we'll paste this in here instead of set text name we'll just say composing message and this will allow us to see how this works and then what you can do is you can build upon this system to do more complex things based on if the value is null or not so in this situation it's null and it just says composing message instead of being blank or instead of saying writing a message to John so that's how that works now this has its limitations so if we go back obviously we don't want it to just say composing message we wanted to say composing a message to John because we clicked on John but what if we wanted this fourth button down here that just said compose a message and we didn't have a name there and we wanted to say something different and maybe instead of having just the words composing message what if we actually had a different view there and edit text where we could type in the value so there's a couple of different ways you can do this one you could you could generate that view programmatically and position that on the the screen that works might be a little bit complicated and there's also specific views for swapping views which you can look those up as well well there's actually a third way which seems a little brute force but it's actually the easiest is just to toggle the visibility of different views based on whether a value is null or not so what we're gonna do in the next episode is we're going to make is such that when you click this bottom button it says it gives you the option to type in someone's name and when you click one of these buttons it says that person's name already so that's we're going to be doing so check out the next episode and yeah it should be pretty fun so see you then [Music]
Info
Channel: Caleb Curry
Views: 377,885
Rating: undefined out of 5
Keywords: android, android development, android developer tutorial for beginners, android development tutorial, android java, android app, android programming, app development, how to make an app, java, caleb curry, caleb, curry, beginner, code, coding, programming, android app development, android tutorial, how to
Id: tZvjSl9dswg
Channel Id: undefined
Length: 234min 35sec (14075 seconds)
Published: Fri Jun 05 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.