List Implicit : List « J2ME « Java






List Implicit

List Implicit
//jad file (please verify the jar size)
/*
MIDlet-Name: ListImplicit
MIDlet-Version: 1.0
MIDlet-Vendor: MyCompany
MIDlet-Jar-URL: ListImplicit.jar
MIDlet-1: ListImplicit, , ListImplicit
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0
MIDlet-JAR-SIZE: 100

*/
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;

public class ListImplicit extends MIDlet implements CommandListener {
  private Display display;

  private List list = new List("Menu:", List.IMPLICIT);

  private Command exit = new Command("Exit", Command.EXIT, 1);

  Alert alert;

  public ListImplicit() {
    display = Display.getDisplay(this);

    list.append("New", null);
    list.append("Open", null);
    list.addCommand(exit);
    list.setCommandListener(this);
  }

  public void startApp() {
    display.setCurrent(list);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command command, Displayable displayable) {
    if (command == List.SELECT_COMMAND) {
      String selection = list.getString(list.getSelectedIndex());
      alert = new Alert("Option Selected", selection, null, null);
      alert.setTimeout(Alert.FOREVER);
      alert.setType(AlertType.INFO);
      display.setCurrent(alert);
    } else if (command == exit) {
      destroyApp(false);
      notifyDestroyed();
    }
  }
}


           
       








Related examples in the same category

1.List DemoList Demo
2.List CheckBoxList CheckBox
3.List RadioButtonList RadioButton
4.GUI Test in MIDletGUI Test in MIDlet
5.Travel ListTravel List
6.Payment MIDletPayment MIDlet
7.multiple Choice Listmultiple Choice List
8.Implicit ListImplicit List
9.List Item MIDletList Item MIDlet