SyntaxHighlighter

Saturday, September 11, 2010

Android Programming Jumpstart - 2

imageThis is part two of the series of labs providing quick ramp up on programming for the Android environment.

As I stated in part 1, normally I use Motodev or Eclipse. 

 

 

This is where we left of last time.  We had made our first hello world style project.  But it wasn’t very impressive.image

Let’s expand the project to add a button that will pop up a message to the user. 

It isn’t very difficult to do but it will expose a few new ways of working with the IDE.  In your IDE project outline under the res/layouts folder you will find your main.xml.  This is where you can either edit the XML directly (which I like to do) or you can use the Layout editor to drag in a button and then use the properties to update the Button’s attributes.  The layout view is not up to the level of a MS Visual Studio project, but it is still useful.  Feel free to deviate from what I have defined below and try it for your self.

image

Let’s review a little bit about the IDE.  One of the things is that the compiler will try to help you by catching that there are imports you need.  However as your projects get larger you may want to turn off the auto-build feature.  In the example below we haven’t finished typing in the code for a Toast (a pop up type of notification) so it flags as an error.  Also displayed are some of the nice information features of Motodev/Eclipse.  Play with your IDE to learn more.  Don’t be afraid.

image 

Here are the basic steps needed to be done at this point.

image

Now when we build the project and run it on our AVD we get the following.  Congratulations, you created an interactive Android widget!

image

No comments:

Post a Comment