Beginning Android Programming

Google’s Android  platform has taken the mobile world by storm. In this introductory series on programming with Android, we will be introducing the basics of how to create Android mobile applications. The first example is kept simple and we will follow the traditional “Hello World” program.

Steps involved:
Create a New Android Project by clicking the Android Icon ( Or File->New->Other and Select Android -> New Android Project)
Lets name it HelloWorldAndroid.


Specify the following details:
Project Name: HelloWorldAndroid (you can change to whatever you want)
Select a Build Target: Android 1.5
Application Name: HelloWorld
Package Name: com.isobar.examples
Create an Activity: Main

Eclipse automatically generates the Android Project Structure:
Take a minute to familiarize yourself with the Project Layout structure to better help navigate yourself around an

Folders generated:

src/ –  Source folder contains all your Java source code

gen/ – Generated folder contains source code generated by Android/Eclipse. Well it only contains R.java – one of Android’s most important file to perform name lookup/resolution and referencing. R.java is automatically generated by the build system and references your resources.

assets/ – Assets folder contains static files such as html which can be included in your program.

res/ – Resource folder contains your program resource files.

res/drawables/ – Contains image files eg. PNG, JPG etc but also drawables which are specified in XML format

res/layouts/ – Contains XML files to specify your application View layouts

res/values/ – Contains XML files where you can specify static string,text, numeric and other constant values.

Referenced Libraries/ – A folder containing third-party/downloaded JAR libraries which can be used in your Android App.

AndroidManifest.xml – A manifest file where you can specify all you Activities, Permissions, and other configurations.

File: main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical"
	android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<TextView
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:text="Hello World Android" />
</LinearLayout>

File: Main.java

import android.app.Activity;
import android.os.Bundle;

public class Main extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}


Add a comment