Source code explanation – Part 1

Let’s start by letting you download the source code. Feel free to do what you will with this code!

DublinBuzz

WordPress has forced me to upload a document file format, so you need to load this text into your favourite Java editor and save with a .java extension!

The opening bit of code in the main activity just declares some essential variables. An Activity is Android’s version of a form (kinda). The DublinBuzz activity is the display for the list of sights. So that’s our first variable – viewable – which always holds the current list of sights. The rest are fairly self-explanatory. DublinBuzzer is the name of the Application class. This is used to hold state between orientation changes. We’ll talk about that later.

OnCreate is the event handler called when the activity first starts up. It should only get called once in the lifetime of the activity, so it can be useful for setting things up initially. The method call setContentView just tells the activity where to find its XML layout page (in this case, called “main”). The app variable holds a singleton instance of the Application class.    

That’s the first bit…off now to enjoy a night out in….Dublin! Be back to explain (much) more later.
Tony

This entry was posted in Android, Android development, Mobile Apps. Bookmark the permalink.

Leave a comment