Thursday, 13 September 2012

Hello world Tutorial in android | Android Hello world tutorial

Today, I am going to show you how to create Hello world example. I am assuming that you have successfully installed the android sdk in your PC. In this turn, you need to follow some steps:

Step-1:

Open Eclipse click on file>new>android project


Then write your AndroidProjectName 'HelloWorldExampel' and click on next then select the sdk target (suppose android 2.2). Click on next and write the package name com.androiseeker.helloworldexample Then click finish.

Step-2:

Now Click on your project folder>src>com.androidseeker.helloworldexample>HelloWorldExampleActivity.java


package com.androidseeker.helloworldexample;

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

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


Let this java file remain as it is.

Step-3:

Now click on project folder>res>layout>main.xml and replace the paste this code.


<?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="Hello AndroidSeeker!" />

</LinearLayout>


Step-4:

Now run as android application


For any help do comment.

Thanks!!!


4 comments: