Twitter Delicious Facebook Digg Stumbleupon Favorites More

Selasa, 22 Januari 2013

Android Hello, World !!



Menampilkan Hello, World !! di Android.

File > New > Other > Android Aplication Project. 


/HelloWorld/src/com/helloworld/HelloWorldActivity.java
package com.helloworld;

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

public class HelloWorldActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }

}

/HelloWorld/res/layout/main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context=".HelloWorldActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

</RelativeLayout>

Dan Hasilnya setelah di compile.



0 komentar:

Posting Komentar

 
Design by Free WordPress Themes | Bloggerized by Mahasewa - Premium Blogger Themes | Blogger Templates