Filename | Membuat Menulist / daftar menu di java (merancang apps mobile) |
Permission | rw-r--r-- |
Author | Artikel |
Date and Time | 06.21 |
Label | java |
Action |
import javax.microedition.lcdui.*;
public class menulist extends MIDlet implements CommandListener{
Alert tampil;
Display layar;
Command keluar, m1, m2;
Ticker jalan;
List ls;
public menulist(){
tampil = new Alert("Menu Utama","Silahkan Pilih Menu",null,AlertType.INFO);
keluar = new Command ("Keluar",Command.EXIT,0);
m1 = new Command ("Keluarga Ku",Command.OK,0);
m2 = new Command ("Teman ku", Command.OK,0);
jalan = new Ticker ("Pertemuan ke 4");
tampil.setTicker(jalan);
tampil.addCommand(keluar);
tampil.addCommand(m1);
tampil.addCommand(m2);
tampil.setTimeout(Alert.FOREVER);
tampil.setCommandListener(this);
}
public void startApp() {
layar=Display.getDisplay(this);
layar.setCurrent(tampil);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command x, Displayable arg1) {
if (x==keluar){
destroyApp(true);
notifyDestroyed();
}
if(x==m1){
ls=new List ("list Keluarga ku",List.IMPLICIT);
ls.append("ayah",null);
ls.append("ibu", null);
ls.append("adik", null);
ls.setCommandListener(this);
layar.setCurrent(ls);
}
if (x==List.SELECT_COMMAND){
int i=ls.getSelectedIndex();
String p=ls.getString(i);
if (p=="ibu"){
tampil=new Alert("Ibu","Nama",null,AlertType.INFO);
tampil.setCommandListener(this);
layar.setCurrent(tampil);
}
}
if(x==m2){
ls=new List ("daftar teman",List.IMPLICIT);
ls.append("1. Herbet", null);
ls.append("2. Topeng", null);
ls.append("3. KillerByte", null);
ls.append("4. Harrie", null);
ls.setCommandListener(this);
layar.setCurrent(ls);
}
}
}