Membuat “Hello World” di Android Menggunakan Eclipse

{ Posted on Mar 10 2010 by Achmad Fachrie }
Tags : , ,
Categories : linux-open source

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);
}
}

Perbedaannya yang saya cetak tebal. Hasilnya :

Reblog this post [with Zemanta]

Related posts:

  1. Membuat Aplikasi Google Map di Android
  2. Hello World di Android Menggunakan XML
  3. Setting Emulator Android di Eclipse
  4. Install dan Konfigurasi Plugin Android di Eclipse
  5. Membuat Password-protect Pada web menggunakan .htaccess

[ Back to Top ]