Android Application Development Tutorial for Beginners – #3 | 2017 | Java & importing Variables [w/ subs]



00:00:00 – ♫Intro Music Playing♪
00:00:07 – what's going on guys welcome back to the
00:00:09 – brand new android app development
00:00:11 – tutorial and this is the 3, where we are
00:00:14 – going to take a look at how to program a
00:00:17 – android app so in this case i'm now
00:00:20 – first of all i'm going to open the
00:00:21 – android studio so yeah we have the dark
00:00:25 – dracula background for the android
00:00:27 – studio from the last tutorial so what I
00:00:30 – want to do is changing the background
00:00:31 – into white again so going to the
00:00:33 – configure selecting the settings now
00:00:37 – going to the up your end and from here
00:00:39 – I'm going to go with DJ clicking that
00:00:42 – play and there you go ok so let's kind
00:00:45 – of new to that our Android app project
00:00:47 – so everything is done really faster
00:00:50 – because we are using this continuously
00:00:52 – again ok anyway today what we are going
00:00:55 – to do is that so first of all before
00:00:58 – that I want to say that we have a text
00:01:00 – view inside this app we have a button so
00:01:04 – I'm going to go and use this button in
00:01:06 – this tutorial and it I want to remove
00:01:08 – this text view so I'm going to delete
00:01:10 – that one ok so now we can see we have a
00:01:15 – layout file with a button and looking to
00:01:18 – the button we can see here is a text
00:01:20 – that is quick me used to the string
00:01:22 – resource now at the top you can see here
00:01:25 – is a button i ed that android colon ID
00:01:28 – equal to i plus ID / button so what we
00:01:32 – are going to do is them how to add an
00:01:34 – action when the button or the user
00:01:36 – presses button we have to add an action
00:01:38 – so action can be anything like changing
00:01:42 – the button text or changing the button
00:01:44 – color or background color or even we can
00:01:48 – use the external item as a result so
00:01:50 – like that when i when they use to click
00:01:53 – that we can also give a popup message
00:01:55 – saying that yeah you click the button so
00:01:57 – language we can do anything by a symbol
00:02:00 – button click so all you have to do is
00:02:02 – you how to just remember the name for
00:02:04 – the ID of this product so in the in this
00:02:07 – case we have the ID as button let's go
00:02:09 – to the main activity
00:02:11 – door Java you can find the same file as
00:02:13 – I said you can find it by going to the
00:02:15 – main root folder that is app and instead
00:02:18 – that we can see the Java and go to the
00:02:21 – first folder inside the Java and here is
00:02:24 – the main activity don't Java ok anyway
00:02:27 – we how we'll discuss about the main
00:02:29 – activity and the structure of this main
00:02:31 – activity and the java files in the first
00:02:34 – tutorial so anyway once again I am
00:02:36 – repeating here is the package name that
00:02:38 – you have given at the first or at the
00:02:40 – beginning and here is the inboard and
00:02:42 – public class and inside that two
00:02:45 – bracelets open and close we have the one
00:02:50 – create method added here so first of all
00:02:53 – here is the package name and everything
00:02:55 – is here and now let's go and before
00:02:58 – adding a button we have to be familiar
00:03:00 – with this course so we have used it a 10
00:03:03 – / right protected void one create method
00:03:06 – and so this method insert some of the
00:03:09 – main elements required for your android
00:03:12 – app so you know when you're looking to
00:03:14 – this course you can see here is a matter
00:03:17 – which we can easily identify what the
00:03:19 – use of this so here it is Ted content
00:03:21 – view and in the bracket you can see that
00:03:24 – is outdoor layout door activity been so
00:03:27 – so the content view is a method that
00:03:30 – used to set the layout of the Android
00:03:33 – Apple as corresponding to this class
00:03:37 – file so language and this as the Jaguar
00:03:40 – is a high-level language as the high
00:03:42 – level languages are similar to the
00:03:43 – English words it is easy for us to
00:03:46 – identify each course so anyway what we
00:03:49 – have to do is that we're going to be
00:03:51 – adding a button as I said so we have the
00:03:53 – IED for the button a** button again and
00:03:55 – we are going to the main activity and
00:03:57 – reducing the button here so under the
00:03:59 – public class mainactivity extends up
00:04:01 – compact activity than bracelet under
00:04:03 – that we how to add a line that is but
00:04:07 – tan ok now you can see when i type
00:04:09 – button you can see here it shows in
00:04:11 – blood clot which means which represent
00:04:13 – that there is error and the error is
00:04:16 – that cannot resolve symbol button so
00:04:19 – that means java cause cannot identify
00:04:21 – that user type of value
00:04:24 – user type character so that means all we
00:04:27 – have to do is that when we are inserting
00:04:30 – a widget into the Java class how we have
00:04:33 – to do is just type it like an upper
00:04:36 – caste letter at the first let me type x
00:04:39 – button so when i type button you can see
00:04:42 – here is a proper shows that do you want
00:04:45 – to import the button as a widget into
00:04:48 – this category so I language that's all
00:04:51 – you have to do is just double click on
00:04:52 – the button now you can see it's added a
00:04:55 – one more line in both android widget
00:04:58 – button then semicolon so let me remove
00:05:01 – that one thing okay now again I'm typing
00:05:04 – button so if you haven't seen this
00:05:07 – pop-up you can also if you if you're
00:05:10 – only getting a similar that you would
00:05:13 – only return that and but you doesn't get
00:05:14 – a pop-up than the alley how to do is
00:05:17 – just keep your mouth or the character
00:05:20 – just give it a one most button left
00:05:22 – click then and then you'll be getting a
00:05:25 – pop up like this if you if you haven't
00:05:27 – yet no problem just just press all the
00:05:30 – end there just like how you have
00:05:32 – extracted the string in the activity
00:05:34 – main.xml in our series to like this when
00:05:38 – you press alt enter you can also import
00:05:40 – the same button through the top up so
00:05:43 – finally we have we added a button but
00:05:46 – what happens if the user has more than
00:05:48 – one button let's see okay i'm going to
00:05:51 – copying the same now changing the button
00:05:54 – into button to button three okay now as
00:05:58 – you can see i have three buttons in my
00:06:00 – activity and i want to i want to add
00:06:04 – each click listener for each of these
00:06:06 – buttons so adela can can identify which
00:06:09 – the button we are intending to add a
00:06:12 – click or what we are going to do with
00:06:15 – that particular button so all we have to
00:06:17 – do is we have to view name for each
00:06:20 – balance so like where it's in case of
00:06:22 – java programming or many other languages
00:06:24 – we call the name as variables so the
00:06:27 – variables are a particular type of
00:06:30 – characters that represent each balance
00:06:32 – so like ways let me show you an example
00:06:34 – so this is the first we have introduced
00:06:37 – the button
00:06:38 – to this devil class and now we have to
00:06:40 – insert a variable of name for each
00:06:43 – button so let me go with the BT so I
00:06:46 – represent the button as BTW so let's
00:06:49 – suppose i only have a single button now
00:06:52 – i have added a bt let's let's add a
00:06:55 – beating one ok now it's buried one now
00:06:58 – if you want to add the second button all
00:07:01 – you have to do is just copy this again
00:07:05 – face it here and change that video won't
00:07:07 – ability to so now you can see if i have
00:07:11 – a 100 button I should keep doing this
00:07:14 – all the line but it is rotating it is
00:07:17 – that doesn't make any sense of writing
00:07:19 – an android app instead of in that case
00:07:22 – instead of making an android app you can
00:07:24 – do it manually so our goal is to make
00:07:27 – everything simplified so for that you
00:07:30 – have to simply if you have multiple
00:07:32 – button you have to simply add a comma 1
00:07:36 – after one variable then again give you a
00:07:39 – space or not for a beauty i'm giving it
00:07:42 – a space again i'm typing the BD to again
00:07:45 – giving the comma again giving it stays
00:07:48 – and having the third one bt 3 now you
00:07:53 – can see there is no error up to this but
00:07:55 – the final you can see here is a small
00:07:57 – error that is expected a semicolon so
00:08:01 – Java is as I said before the Java is
00:08:04 – much very easy to learn so so you will
00:08:07 – be reminder about the mistake that you
00:08:09 – have done in the program so like wait
00:08:11 – here it is expected semicolon so why not
00:08:14 – we can give it a semicolon let's add a
00:08:16 – semicolon now as you can see there is no
00:08:18 – any kind of errors and even the main
00:08:20 – activity door java I would know any kind
00:08:22 – of errors when I remove the semicolon
00:08:25 – you can see here it shows a red
00:08:28 – underline that means that represent the
00:08:30 – arrow again I'm adding it now there is
00:08:33 – no errors so like ways we can add more
00:08:35 – and more button into this so I'm gonna
00:08:38 – go with this one on one and reviewing
00:08:40 – all the other buttons now like with am
00:08:42 – removing all other burns
00:08:44 – from the layout now we only have a
00:08:47 – button so the ID of the button is button
00:08:50 – itself let me go back to the main
00:08:53 – activity to Java now we have to add a
00:08:56 – listener for the button so when they use
00:08:58 – the press the button we have to give a
00:09:00 – certain activity for action for the
00:09:03 – button click so like that language all
00:09:05 – you how to do is under the sit command
00:09:07 – view we have to view some other lines so
00:09:12 – the first line is to be introduced
00:09:16 – button inside this one credit method so
00:09:18 – all you have to do is just type VT 1 so
00:09:22 – that is the variable name of the first
00:09:24 – button so be d 1 equal to what is that
00:09:28 – what is BD one so what you have written
00:09:30 – is only up to here what that one create
00:09:33 – method doesn't know what you have
00:09:34 – written about we how to teach that one
00:09:37 – create method what we have given at the
00:09:39 – top so like ways we how to add be t1
00:09:41 – equal to and inside the bracket you how
00:09:44 – to type button so you have to add the
00:09:47 – variable and main head for the variables
00:09:50 – inside the bracket so once you have
00:09:52 – added button inside the bracket all you
00:09:54 – have to do is just I prob find view by
00:09:57 – ID so you don't have to type fully by
00:10:00 – just pressing enter that will be auto
00:10:02 – completed now we can see shows that hid
00:10:05 – rust in the ID so in this case it says
00:10:08 – that you how to mention the ID for these
00:10:12 – variables so we have the first variable
00:10:14 – beauty and in the activity man we can
00:10:17 – see here is a button that the ID name of
00:10:19 – this pattern so like this we're going to
00:10:22 – be adding them ID for introducing the
00:10:25 – idea into this one create method so
00:10:27 – outdoor LED door button so now we have
00:10:32 – then finally or it again expected a
00:10:34 – semicolon so all you have to do is just
00:10:37 – added ok now there is no errors so now
00:10:41 – the oncreate method know what is
00:10:43 – believed one so finally we have teacher
00:10:46 – the one create method that BD one easy
00:10:49 – balance so again finally we have to add
00:10:50 – VT 1 again then now in this time we have
00:10:54 – to add dot
00:10:56 – then set one click listener so when I
00:10:59 – tab said we wanna click listener you can
00:11:01 – see the pop-up you can see that one
00:11:03 – click missionaries already Sean let's
00:11:05 – click on that I just double click on the
00:11:09 – first result from the pop-up now you can
00:11:12 – see again expected something inside this
00:11:15 – bracket so all we have to do is just
00:11:17 – type a new because this guy you see a
00:11:19 – new anywhere one click listener so when
00:11:22 – i type new one click listener you can
00:11:24 – simply double-click on the faster
00:11:26 – results shown on the crop up okay double
00:11:29 – click now as you can see when I double
00:11:31 – click on them onclicklistener all these
00:11:33 – lines are already returned by the
00:11:36 – Android studio so that make really more
00:11:38 – easier to type each course so even at
00:11:41 – this point I didn't get any kind of
00:11:43 – errors that you can you clarify if there
00:11:46 – is any kind of errors by looking to the
00:11:48 – main activity dojo or whether it has the
00:11:50 – underline or not anyway we have the
00:11:52 – public void one click view dot view and
00:11:54 – blah blah blah many other things so all
00:11:56 – you have to do is if you want to give an
00:11:59 – action for this button all you have to
00:12:00 – do is just add the action under the
00:12:03 – public void one click method so in case
00:12:06 – of button and many other things we have
00:12:08 – to use one click method to show or give
00:12:12 – an action for the button so in my case
00:12:13 – we have the button vd1 okay so Billy one
00:12:17 – is the variable name that we have given
00:12:19 – for the button so b1 do so what we had
00:12:22 – to do so in this case we have where many
00:12:26 – options that we can follow up so let's
00:12:29 – suppose we want to show a popup message
00:12:31 – when the BD one is clickable so again
00:12:35 – I'm remaining the b1 is this pattern so
00:12:37 – when the user is in the app when the
00:12:40 – user presses button we have to add a
00:12:42 – certain message to be pop it up when the
00:12:46 – user presses again ok so I'll be how to
00:12:48 – do is in in Android app development we
00:12:51 – have a method that is toast which shows
00:12:54 – the popup message for the users so I'm
00:12:57 – going to go with the popup message I
00:12:59 – want to show popup message when the user
00:13:01 – click this button so all you have to do
00:13:03 – is simply we have the type for toast
00:13:05 – leather
00:13:06 – bob is known by the name tossing that
00:13:08 – java programming when i type with close
00:13:10 – you can see also its imported the
00:13:12 – android widget toast so totes easier
00:13:15 – part of rigid in the android okay anyway
00:13:17 – so all we have to do is decide toast so
00:13:20 – toast or make text then again get
00:13:22 – application conducts then come up and
00:13:25 – your text here again add comma and we
00:13:28 – have to give them toast.length duration
00:13:32 – or whatever else you want call it okay
00:13:36 – now you can see how added the set of
00:13:39 – exhaust and the matter and here is the
00:13:41 – popup message and we have also
00:13:43 – introduced the time duration for the
00:13:46 – toss and finally we have added dog show
00:13:48 – so if we further to add the dog show and
00:13:52 – we just completed the toast by a
00:13:54 – semicolon the toast is not going to walk
00:13:57 – in an android app so we have to finally
00:14:00 – add those show and we have to shop with
00:14:02 – the semicolon so at this time we have
00:14:05 – seen there is no any other kind of
00:14:07 – errors we have done with this soul and
00:14:10 – so final step is that we gonna run this
00:14:13 – app in a live device and check that out
00:14:15 – in order to run your app on a lab device
00:14:17 – you how to connect your android device
00:14:19 – through the USB cable and make sure that
00:14:22 – you have installed the USB drivers
00:14:24 – corresponding to your android device so
00:14:27 – once you have connected you how to go to
00:14:29 – the run which you can see here you see a
00:14:32 – green button or you can go to the run
00:14:34 – from here and run the app and you can
00:14:36 – also use the shortcut shift + f10 so i
00:14:41 – want to click on the this button you can
00:14:43 – see here we have the option to select
00:14:45 – the deployment target so i have
00:14:48 – connected my personal phone to the USB
00:14:50 – cable and you can see here it is
00:14:51 – connected so now and I selected this one
00:14:55 – clicking on the youth same selection for
00:14:58 – future lon just because I want to use
00:15:00 – the same device and I want to launch in
00:15:02 – the future so that you can avoid getting
00:15:04 – the sims window so finally you how to
00:15:07 – select your device and click on the ok
00:15:10 – and there you go once that is complete
00:15:13 – you can see you our Android app will be
00:15:16 – running on your life device or yea you
00:15:17 – can see when I press the button the
00:15:20 – message is shown then the prop up is
00:15:23 – shown by a toss I hope you guys enjoyed
00:15:26 – watching this tutorial if you want to go
00:15:27 – more professional you can subscribe to
00:15:29 – my channel and can be watching the
00:15:31 – upcoming series so if you end up with
00:15:33 – any kind of errors you can probably
00:15:35 – comment below and i will be showing you
00:15:37 – the right solution for that thanks for
00:15:40 – watching either hope to see you in my
00:15:41 – next tutorial


Video Url:
http://youtu.be/pmlNTbZP2_A

Comments

comments