Before starting creating android application you must have setup environment for android development.
I hope that you have already done that if not then do it by following this link .
I hope that you have already done that if not then do it by following this link .
Creating a new Android Project in Eclipse
1: Click On File -> New -> Project
you will see a dialog, click on Android Project See picture
2: Click on Next button.
3: Write the name your project or application . Here for this project I am using "My First App"
4: Click on Next choose a target
5: Click on next.
You see following dialog. Fill in the fields: see picture
Click on Finish buttton.
Your project named "My First App" is created and you can see in left pane under Package Explorer.
You will see some folders that are automatically created like Gen, Res,bin, Src etc.
Now you have to edit your main.xml file.
Editing main.xml file
1. Double click on"Res" folder in left pane under Package Explorer.
2. Double Click on "Layout"
3. click on main.xml.
modify the main.xml file , it should look like( you can just copy this and paste in main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My First Android Application" />
</LinearLayout>
public class FirstActivty.java extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="My First Android Application" />
</LinearLayout>
FirstActivty.java
public class FirstActivty.java extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Now right click on your project name and select "Run As" then click on "Android Application".
It will start the emulator, wait for the emulator to show the output.
You will see following
Hence you have created your first Android Application..
I have tried to make the things clear hope you enjoyed it.
Comments are welcome.