Thursday, April 19, 2012

Create Your first android program

During the last post we discussed how we set our environment so that we can start mobile app development. Today will discuss the programming part. Really the fun part....



1. Open Eclipse. File--> New--> Project 
Select android project --> Give a name for your project


Select the Android OS that you wish to run your app.--> give the package name and finish the wizard.






2. Double click helloworld activity.java




3. Copy the following code in it.



package com.muo.helloworld;


import android.app.Activity;


import android.os.Bundle;


import android.widget.TextView;


public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("welcome to android development");
        TextView tv1 = new TextView(this);
        tv1.setText("with hudha zainudeen");
      
        setContentView(tv);
        setContentView(tv1);
        
    }
}



4. Save the project and run the program. (In the menu bar select run-->run or press ctrl+F11)




5. Your beautiful program will look like this.






Congratulations. You have created your first app and testes successfully. 





No comments:

Post a Comment