Buat project baru :
1. New project > Java ME > Mobile Application > Nama Project (Listener) > (pada device profile) pilih MIDP-2.0 (Nokia Symbian).
2. New > Java Package > Nama Package (Listener).
3. Kemudian New > MIDlet.. > Nama MIDlet (Listener)
4. Pada class Listener copykan script
package Listener;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Listener extends MIDlet implements CommandListener {
Display display;
List list;
Command exitCommand = new Command("Exit", Command.EXIT, 1);
Command newCommand = new Command("New item", Command.OK, 1);
Command renameCommand = new Command("Rename item", Command.OK, 1);
Command deleteCommand = new Command("Delete item", Command.OK, 1);
Ticker ticker = new Ticker ("JEDI - Java Education and Development Initiative");
public Listener(){
list = new List("JEDI: List Example", List.IMPLICIT); // ( Tipe list ) List.EXCLUSIVE, List.MULTIPLE
list.append("List Item #1", null);
list.append("List Item #2", null);
list.append("List Item #3", null);
list.setTicker(ticker);
list.addCommand(exitCommand);
list.addCommand(newCommand);
list.addCommand(renameCommand);
list.addCommand(deleteCommand);
list.setCommandListener(this);
}
public void startApp() {
if (display == null){
display = Display.getDisplay(this);
display.setCurrent(list);
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand){
destroyApp(true);
notifyDestroyed(); //exit
}
if (c==List.SELECT_COMMAND){
int index = list.getSelectedIndex();
String currentItemm = list.getString(index);
// menjalankan suatu hal
}
}
}
Tidak ada komentar:
Posting Komentar