Friday, September 3, 2010

My first Android app - TicTacToe

As you see the market for android phones is expanding, all the major brands have released devices that run Android platform. Android being open source shows a bright future and has lot of scope for development. Today i tried creating an application on Android 2.2 platform and it is so much fun. To start creating your own apps you need to first download Android SDK (and read installation notes). This has a package manager that lets you download all the platforms you want to work on. You can also integrate it with Eclipse The SDK allows you to create virtual devices (Android Virtual Devices or AVD) on which you can test your app.



The app consists of 2 parts, one is the layout or the UI and second, the functionality. The layout is defined in an xml file. Below is the main.xml file code for my TicTacToe application.




The layout structure is similar to html if you see, you have tables, buttons, labels, textfields at your disposal.

The functionality is defined in java language. Below are the contents of my java file.



onCreate() is a function that is called when app starts so you can mark you entry point there. setContentView() lets you set one of the layouts available. findViewById() is used to map the elements in the xml to objects in java (for eg. buttons).

These two components are integrated in a way that allows cross access to resources.
Download the TicTacToe Android source here and the TicTacToe Android application package here.

6 comments: