List

|
List มันจะกินที่ทั้ง main pane แล้วก็แสดงลิสต์ มี 4 attribute 4 อย่าง list type, icon, font และ fit policy for long elements
List เหมือน ChoiceGroup ของ Form และใช้ Interface เดียวกับ Choice

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ExampleList extends MIDlet implements CommandListener {
private List ls;
private Command exit;

public ExampleList() {
//List(label,type,items,Images)
ls = new List("Multiple list", List.MULTIPLE, new String[] {"Choice 1", "Choice 2", "Choice 3", "Choice 4"}, null);
exit = new Command("Exit", Command.EXIT, 1);
ls.addCommand(exit);
ls.setCommandListener(this);
}
public void startApp() {
Display display=Display.getDisplay(this);
display.setCurrent(ls);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable displayable) {
if (command == exit) {
destroyApp(false);
notifyDestroyed();
}
}
}

0 ความคิดเห็น:

แสดงความคิดเห็น