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

Sharing buttons:

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


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


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


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


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


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


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


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


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


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 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


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


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


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 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 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


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


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 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


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


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


alright so what are we talking about

we're gonna be talking about the our


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



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


sure hey what's going on everybody this

episode what are we gonna be talking


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


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


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


so our app should work exactly the same

way we just put something on here

press button and look it shows up right


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


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


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


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 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


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


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


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