?? listdemo.java
字號:
package ch09.section01;
import javax.microedition.lcdui.*;
//列表實例類
public class ListDemo
extends BaseListDemo {
//列表類型
private static final String[] listTypes = {
"Exclusive", "Implicit", "Multiple"};
//創建一個列表實例
public ListDemo() {
super("請選擇列表類型", listTypes);
}
protected Runnable[] getListCallbacks() {
//該類用于顯示列表
class DisplayList
extends List
implements Runnable, CommandListener {
//點擊返回的上一層父類
private Displayable parent;
public DisplayList(String listLabel,
int listType,
String[] data,
Image[] images,
Displayable parent) {
super(listLabel, listType, data, images);
addCommand(new Command("返回", Command.BACK, 1));
setCommandListener(this);
this.parent = parent;
}
public void run() {
Display.getDisplay(UIDemo.getInstance()).setCurrent(this);
}
//響應按鈕事件
public void commandAction(Command c, Displayable d) {
if (c.getCommandType() == Command.BACK) {
Display disp = Display.getDisplay(UIDemo.getInstance());
disp.setCurrent(parent);
}
}
}
String[] stringArray = {
"Option A", "Option B", "Option C"};
//創建列表形式的選擇組
Runnable[] lists = {
new DisplayList("Exclusive", ChoiceGroup.EXCLUSIVE, stringArray, null, this),
new DisplayList("Implicit", ChoiceGroup.IMPLICIT, stringArray, null, this),
new DisplayList("Multiple", ChoiceGroup.MULTIPLE, stringArray, null, this)
};
return (lists);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -