Android Tutorials
Working With Android Contacts
Accessing Data With Android Cursors
Creating Lists Using The Android ListActivity
Android 9 Patch Scaled PNG Image Guide
Working With Images In Android
Exploring Android LinearLayout And RelativeLayout
Writing A Basic Android Application
Installing The Android SDK In Eclipse

Writing A Basic Android Application


This tutorial assumes you have a decent knowledge of Java, and have already installed the Android SDK and Eclipse Plugin. Visit the Installing Android SDK tutorial to get the Android SDK and Eclipse plugin installed. The application built in this tutorial will demonstrate how to do various tasks in Android over making a truly productive application. The tutorial starts slow with creating a project.

Create A New Android Project

Open Eclipse and go to New Project > Android Project. Enter the following information to create the project.

Eclipse Install Android SDK Continued

The base project created for Android is a hello world implementation.

Setup Application Resources

Google did an excellent job creating a project layout that allows you to easily separate data from code. The res/ directory in the project stores layout, images, and application data. Localization data is also stored in this directory, but that's beyond the scope of this tutorial.


Now Open res/values/strings.xml Since the application is going to demonstrate how to use different features, change the hello string value to instruct the user to push one of the below buttons. Next add a string named button_dialog_text by clicking add then select string and press OK. A new String will appear in the list and the input fields to the right should be blank. Enter "button_dialog_text" in the name and "Show Dialog Box" in the value fields both without quotes and click the new String resource on the left side. Do the same for button_sound_text with the value "Play Sound".

Eclipse Install Android SDK Continued

At the bottom of the pane there are 2 tabs, resources and strings.xml. Click the strings.xml tag to view the raw XML of the file. Manually add a new string with a name of "button_relative_text" and a value of "Show Relative Layout". The XML tag should look like Show Relative Layout. Before we move on to setting up layouts add the following strings to the XML file. We'll use these later.

<string name="button_update_text">Update</string>
<string name="dialog_title">Dialog Box Title</string>
<string name="dialog_text">Click OK or Cancel to close</string>
<string name="dialog_ok">OK</string>
<string name="dialog_cancel">Cancel</string>
<string name="sound_file">/sdcard/moonbeam.ogg</string>

New Content