Menu Bertingkat ( android )

package Menu.bertingkat;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MenuBertingkatActivity extends Activity {
/** Called when the activity is first created. */
String[] menuutama = new String[] { “Perhitungan”, “Bangun Datar”,
“Bangun Ruang”, “Keluar Aplikasi” };
String[] bangundatar = new String[] { “Persegipanjang”, “Bujursangkar”,
“Segitiga”, “Lingkaran”, “Menu Utama” };
String[] bangunruang = new String[] { “Kubus”, “Balok”, “Tabung”, “Limas”,
“Menu Utama” };
String[] perhitungan = new String[] { “Penambahan”, “Pengurangan”,
“Perkalian”, “Pembagian”, “Menu Utama” };

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, menuutama));
}
private void setListAdapter(ArrayAdapter arrayAdapter) {
// TODO Auto-generated method stub

}
protected void OnListItemClick(ListView l, View v, int position, long id) {
OnListItemClick(l, v, position, id);

Object o = this.getListAdapter().getItem(position);
String pilihan = o.toString();
if (pilihan.equals(“Perhitungan”)) {
this.setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, perhitungan));
} else if (pilihan.equals(“Bangun Datar”)) {
this.setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, bangundatar));
} else if (pilihan.equals(“Bangun Ruang”)) {
this.setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, bangunruang));
} else if (pilihan.equals(“Menu Utama”)) {
this.setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, menuutama));
} else if (pilihan.equals(“Keluar Aplikasi”)) {
this.finish();
} else {
tampilkanPilihan(pilihan);
}
}

private ArrayAdapter getListAdapter() {
// TODO Auto-generated method stub
return null;
}
private void tampilkanPilihan(String pilihan) {
Toast.makeText(this, “Membuka Form ” + pilihan, Toast.LENGTH_LONG)
.show();
}

}

Downlaod projectnya di

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s