📄 imagelist.java
字号:
package com.j2medev.ch8.mmapi;
import javax.microedition.lcdui.*;
public class ImageList extends List implements CommandListener {
private PowerCamera pc = null;
private Picture[] pic = null;//存储RMS中的Picture数组
private int currentPos = -1;//存储当前浏览的图片
public static final Command backCommand = new Command("返回",Command.BACK,1);
public static final Command nextCommand = new Command("下一个",Command.OK,1);
public static final Command listCommand = new Command("列表",Command.BACK,2);
public ImageList(PowerCamera pc) {
super("图片列表",List.IMPLICIT);
this.pc = pc;
this.addCommand(backCommand);
this.setCommandListener(this);
}
public void initTitle(Picture[] _pic){
pic = _pic;
this.deleteAll();
for(int i = 0;i<pic.length;i++){
Image image = Image.createImage(pic[i].getImg(), 0, pic[i].getImg().length);
//创建缩略图
this.append(pic[i].getTitle(), ImageUtil.createThumbnail(image, 40));
}
}
public void commandAction(Command cmd,Displayable displayable){
if(cmd == backCommand){
pc.back();
}else if(cmd == List.SELECT_COMMAND){
int i = this.getSelectedIndex();
currentPos = i;
showPicture(i);
}else if(cmd == nextCommand){
//循环流览图片
if(currentPos == this.size()-1){
currentPos = 0;
}else{
currentPos = currentPos + 1;
}
showPicture(currentPos);
}else if(cmd == listCommand){
pc.setCurent(this);
}
}
private void showPicture(int i){
//显示图片
Form form = new Form(pic[i].getTitle());
form.append(Image.createImage(pic[i].getImg(), 0, pic[i].getImg().length));
form.addCommand(nextCommand);
form.addCommand(listCommand);
form.setCommandListener(this);
pc.setCurent(form);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -