Sekarang kita coba aplikasi sederhana pada android, yaitu “Hello World”. Pastikan pada eclipse, plugin Android (ADT) sudah terinstall, bisa baca di sini.

1. Setting SDK di eclipse.

SDK nya bisa di download di sini. Untuk menyetting di eclipse. Pilih Window-Preferences-Android-Android Location. Browse file SDK anda.

2. Buat AVD (Android Virtual Device). Mirip seperti sebelumnya. Kali ini bisa dibuat dari eclipse.
a. Pilih Window > Android SDK and AVD Manager.
b. Lalu pilih Virtual Devices, New.
c. Create New AVD.
d. Masukkan Nama AVD anda, misal my_avd.
e. Target. Pilih yang tersedia, misal android 2.0.1

3. Buat Android Project

Pilih menu File – New – Project. Pilih Android.

4. Masukkan :

Project name: HelloAndroid
Application name: Hello, Android
Package name: com.alfach.helloandroid (bebas)
Create Activity: HelloAndroid

Klik finish

5. Lalu di HelloAndroid > src > com.alfach.helloandroid terdapat file HelloAndroid.java dengan isi seperti :

package com.alfach.helloandroid;
import android.app.Activity;
import android.os.Bundle;

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

6. Sekarang kita edit untuk menampilkan Hello World, menjadi seperti ini :

package com.alfach.helloandroid;

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

public class HelloAndroid 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("Hello, Android");
  setContentView(tv);
  }
}

Hasilnya :

Reblog this post [with Zemanta]

Tulisan Lain   Switchr - Task Switching Revolutionized Android

By alfach

Leave a Reply

Your email address will not be published. Required fields are marked *