Did you like how we did? Rate your experience!

Rated 4.5 out of 5 stars by our customers 561

Video instructions and help with filling out and completing Which Form 2220 Credits

Instructions and Help about Which Form 2220 Credits

So I want us to all make a very simple application together and follow along with this it's kind of important that we don't complicate things at first I'm gonna say final new Android application project and I'll call this first GUI and it warns us that comm dot example is not what we should be doing so I'm gonna change that and put my first name there I'm also going to simplify things by making this a one level one API level so it doesn't have to be compatible with the earlier levels and I'm gonna say don't help me with the GUI I don't want a whole lot of stuff added that I don't understand so we're gonna go for the simplest one and I think almost all the rest of it we can allow to default we don't care about the icons right now this one I want us to use an empty activity instead of a blank activity the name of the activity main activity that would be fine and let's see what gets generated for us so here we have the HelloWorld application and we've looked at these folders a little bit and you'll start to get comfortable with them so we have some Java code that it generated for us we have a layout for the main activity we have a manifest that we haven't looked at yet and the class library that we have for the Android SDK is for level 19 4.4.2 which is the current one as of the date of this video so let's go and look at the layout the activity main.xml it opened this for us if it if you can't find it again it's in the resources folder the res and it's under layout and they are XML files so here's the layout for the activity if we double click here we get some more room to work with in the old days you had to below build the the GUI practically by just editing the XML and we're a little bit better off now we have a graphical layout editor and what I want us to do is to put a button on there so let's pick button and as we move it around in here we see different things happening we might say let's put this one towards the top so Center horizontal and below so now we have a button called button actually the button is called button one and it has text on it button so the properties of the widgets are over here in the properties box and the the the the palette the tool palette that we can put on to the GUI is over here and it depends on how how much you want to work with XML but the default layout manager is the relative layout manager and they helped us when we dropped this button on to the GUI they generated this XML for us remember that we saw that it was going to do a center horizontal and it put a margin from the top of 57 density pixels so let's go back here and let's fix the properties of this button a little bit I don't like my buttons to be called button one this is going to be an identifier i mean a java variable name and so you don't want these to start with capital letters because that wouldn't be java convention but I don't want them called button 1 through button 24 let's put something on that button first let's say that this button is going to be called go to green and if we click out of that box it will change the what's written on the button and now I'm going to call this go to green button now because we changed a variable name it's going to have to go through every place that it put that variable already and update it and I want it to do that and I always want it to do that no let's let's let it tell us it when it's doing it for now so if we look around in the properties for the button you'll start to get comfortable with these I clicked off the button so um this widget which is a button has layout parameters that decides where it's going to wind up and then it has the style issues style text of the hint and then the textview everyone else would call this a label but it is a a textview which is on the button and the characteristics of that textview what else do we have here there's a whole lot of properties now there's a view one of the things you can do with a view is specify what to happen what happens when someone clicks on the button the on click so i'm gonna say on go to green so we're making any method name that is an event handler when someone clicks on that button I want this method to execute so the on click property of the button we can specify what method will execute when someone clicks on that button okay so let's save this double click up here to bring back this on the Left let's go over to the main activity so here's the code for the main activity and it has one method in it on create the oncreate method happens only one time when the app is created that makes sense right okay so things that you want to happen only once happen in the oncreate method and one of the things that it does for us automatically is it sets the view for this activity to be activity main the one we were just working in so an activity has associated with it of you I'm going to make a public void on go to green so this is the event handler for the button we put.

If you believe that this page should be taken down, please follow our DMCA take down process here.