📄 listcontrol.java
字号:
/**
* 单选列表框的基础
* The MIDlet demonstrates the different types of list supported by MIDP-2.0:
* EXCLUSIVE - a choice having exactly one element selected at time.
* IMPLICIT - a choice in which the currently focused element is
* selected when a Command is initiated.
* MULTIPLE - a choice that can have arbitrary number of elements
* selected at a time.
*
* @version 2.0
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
/**
* @author long
* 显示最普通的列表
*/
public class ListControl extends MIDlet {
private List mainList;
private Display display;
private boolean firstTime;
public ListControl() {
display = Display.getDisplay(this);
firstTime = true;
}
protected void startApp() {
if (firstTime) {
// these are the images and strings for the choices.
Image[] imageArray = null;
try {
// load the duke image to place in the image array
Image icon = Image.createImage("/Icon.png");
// 注意,每个List选项都需要一个图标
imageArray = new Image[] {
icon,
icon,
icon,
icon
};
} catch (java.io.IOException err) {
// ignore the image loading failure the application can recover.
System.out.print("load failed ...");
}
String[] stringArray = {
"List 1",
"List 2",
"List 3",
"List 4"
};
mainList = new List("Choose type", Choice.IMPLICIT, stringArray,
imageArray);
display.setCurrent(mainList);
firstTime = false;
}
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0){
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -