Pages

Monday, May 28, 2012

first android program example


 Your First Program

first create an xml file with name 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:text="hello to android"
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
</TextView>
</LinearLayout>


paste this code in your first activity class

package yourpackage.name;

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


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

}
}

this is your first hello to Android program.


No comments:

Post a Comment