📄 imageitemdemo.java
字号:
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
public class ImageItemDemo extends MIDlet implements CommandListener {
private Command exitCommand = new Command("退出", Command.EXIT, 1);
private Form mainForm;
private ImageItem pngItem_1,pngItem_2;
public ImageItemDemo() {
mainForm = new Form("ImageItem");
}
protected void startApp() {
mainForm.append("显示各种类型的ImageItem");
try {
//程序创建时添加默认布局的图像
pngItem_1 = new ImageItem("默认图像控件", Image.createImage("/Image.png"),
Item.LAYOUT_DEFAULT, "小猪图片");
pngItem_2 = new ImageItem("默认图像控件", Image.createImage("/Image.png"),
Item.LAYOUT_2|Item.LAYOUT_EXPAND|Item.LAYOUT_NEWLINE_BEFORE, "小猪图片");
} catch (Exception e) {
System.out.println("load image error");
}
mainForm.append(pngItem_1);
mainForm.append(pngItem_2);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener(this);
Display.getDisplay(this).setCurrent(mainForm);
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
protected void destroyApp(boolean unconditional) {
}
protected void pauseApp() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -