I’m teaching myself programming on the android, and I’m a total n00b. I have NO experience in java, and no experience in android either, so I’m really starting from the ground floor. If this sounds like you, check back here often, as I’ll share my experiences, successes, and failures here, so that hopefully you can learn from my mistakes. If these postings make your programming life a little easier, please post a response and let me know!
I don’t know about you, but when I’m working on something “for fun” I generally break all the rules for the design and coding of the project. You can see many examples of this by reading my archives here, or by visiting my other blog about robots. You’ll find lots of fun stuff there, and since it’s all for fun, I generally don’t follow specific “best practices”. In fact, I generally follow the “jump in with both feet and see how you land” practices. This sometimes results in some strange consequences, and projects that wind up looking nothing at all like their original concepts.
Back to android…
I’m developing on a MAC, using Eclipse, and my android devices consist of a Driod and the emulator. I won’t go into detail on how to install and setup eclipse and the android SDK, there are many tutorials on the web; simply google “Developing for Android” to get you started. I’ll start by assuming that you have eclipse, the android SDK installed, and everything is working. With that out of the way, first things first:
Shut down eclipse. Leave it alone for a while. Go download this: DroidDraw. This handy-dandy little tool will let you draw screens much like using visual studio. For me it is an INVALUABLE tool. I can mock up screens, push them over to the device to see how they look, and most importantly, use it to create the layout files (Android uses XML files to define screens) and see how the code looks. I learn by example, and this tool had me designing screens and reviewing code within 2 minutes of downloading. Go get it. You’ll be glad you did.
Using Droid Draw, together with eclipse, I had a basic application laid out in just about an hour, and using it to genrate the xml files, I was able to cut and paste these into the eclipse environment and get my first application running in about 30 minutes. Granted – it wasn’t fancy (just barely beyond “hello world”), but it was mine.
Don’t get too excited. There is still a very steep learning curve ahead, and I guarantee you aren’t going to be making a marketable app in the next day or so, but trust me – if you are a n00b like me, you’ll have fun, and you’ll learn a few things too. Believe me – there is LOTS to learn. It took my 5 days to learn how to build a simple 5 button menu.
For now let me give you a couple of simple pointers….
Your android application is stored in several files. Eclipse lays most of them out for you…. You’ll need a main.xml file – this will hold your main startup screen layout. You’ll need a java file, named after your application. This is your main program file, all code launches from here. You’ll get some System Generated files (main one to think about is R.java – don’t edit this file). You’ll have an android .jar file which holds the android functions and things, and you may have additional xml files that contain string definitions, menu definitions, color definitions and things like that. At first I was completely overwhelmed by the sheer volume of files; but I quickly got used to it. If you are creating a string for a label on a button, for example, you’ll store it in strings.xml. Want a background color for your text? It’s stored in colors.xml.Each screen is names and stored in an xml file. It’s a lot of files, but in an organizational way – it’s handy.
One very important file is your AndroidManifest.xml file. This file is kind of like the main menu of your application… (it’s a poor analogy). You tell the system about activities (tasks or screens), setup information, distribution information and other package information using this file. It’s easy to forget. I’ve forgotten several times. I’ve forgotten so many times that I generally look in this file first to see what I’ve screwed up.
So use Droid Draw, and create a few screens. Get your creative juices flowing. After you get comfortable, putting buttons, checkboxes, changing colors, etc, settle on a simple application, and get started building it. Check back with me. I’ll talk about the things that tripp (or tripped) me up. Hopefully, I can save you some grief, because believe me, there is plenty to be had…. Did I tell you it took me 5 days to get 5 menu buttons to work? Seriously. Lots of help out there to tell you how to use ONE button, but use more than one? Forget it. Look here for my next post!
See ya!
