Posted by : kagome_fitri Rabu, 19 September 2012


Sekarang kita coba aplikasi sederhana pada android, yaitu “Hello World”
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) di 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 :

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Kagome_Aries - Blogger Templates - Powered by Blogger - Designed by Johanes Djogan -