import java.io.IOException;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
public class ListDemo extends MIDlet implements CommandListener {
private static final Command CMD_EXIT = new Command("Exit",Command.EXIT,1);
private static final Command CMD_BACK = new Command("Back",Command.BACK,1);
private Display display;
private List mainList;
private List exclusiveList;
private List implicitList;
private List multipletList;
private boolean firstTime;
public ListDemo(){
display = Display.getDisplay(this);
String[] stringArray = {
"Option A",
"Option B",
"Option C",
"Option D"
};
Image[] imageArray = null;
exclusiveList = new List("Exclusive",Choice.EXCLUSIVE,stringArray,imageArray);
exclusiveList.addCommand(CMD_BACK);
exclusiveList.addCommand(CMD_EXIT);
exclusiveList.setCommandListener(this);
implicitList = new List("Implicit",Choice.IMPLICIT,stringArray,imageArray);
implicitList.addCommand(CMD_BACK);
implicitList.addCommand(CMD_EXIT);
implicitList.setCommandListener(this);
multipletList = new List("Multiplet",Choice.MULTIPLE,stringArray,imageArray);
multipletList.addCommand(CMD_BACK);
multipletList.addCommand(CMD_EXIT);
multipletList.setCommandListener(this);
firstTime = true;
}
protected void startApp() {
if(firstTime){
Image[] imageArray = null;
try {
Image image = Image.createImage("/Icon.png");
imageArray = new Image[]{
image,
image,
image
};
} catch (IOException e) {
e.printStackTrace();
}
String[] stringArray = {
"Exclusive",
"Implicit",
"Multiple"
};
mainList = new List("Choose type",Choice.IMPLICIT,stringArray,imageArray);
mainList.addCommand(CMD_EXIT);
mainList.setCommandListener(this);
display.setCurrent(mainList);
firstTime = false;
}
}
protected void destroyApp(boolean arg0){
}
protected void pauseApp() {
}
public void commandAction(Command c, Displayable d) {
if(d.equals(mainList)){
if(c == List.SELECT_COMMAND){
switch(((List)d).getSelectedIndex()){
case 0:
display.setCurrent(exclusiveList);
break;
case 1:
display.setCurrent(implicitList);
break;
case 2:
display.setCurrent(multipletList);
}
}
}else{
if(c == CMD_BACK){
display.setCurrent(mainList);
}
}
if(c == CMD_EXIT){
destroyApp(false);
notifyDestroyed();
}
}
}
分享到:
相关推荐
基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化压缩PNG文件.zip 基于java的开发源码-J2ME优化...
基于java的开发源码-J2me月光战机游戏源码.zip 基于java的开发源码-J2me月光战机游戏源码.zip 基于java的开发源码-J2me月光战机游戏源码.zip 基于java的开发源码-J2me月光战机游戏源码.zip 基于java的开发源码-J2me...
[j2me开发学习资料].j2me.rar[j2me开发学习资料].j2me.rar [j2me开发学习资料].j2me.rar[j2me开发学习资料].j2me.rar[j2me开发学习资料].j2me.rar
基于java的开发源码-简单模拟的J2ME潜艇大战源代码.zip 基于java的开发源码-简单模拟的J2ME潜艇大战源代码.zip 基于java的开发源码-简单模拟的J2ME潜艇大战源代码.zip 基于java的开发源码-简单模拟的J2ME潜艇大战源...
基于java的开发源码-蜀山剑侠传游戏J2ME手机版源代码.zip 基于java的开发源码-蜀山剑侠传游戏J2ME手机版源代码.zip 基于java的开发源码-蜀山剑侠传游戏J2ME手机版源代码.zip 基于java的开发源码-蜀山剑侠传游戏J2ME...
J2ME飞机游戏含文档.zip J2ME飞机游戏含文档.zip J2ME飞机游戏含文档.zip J2ME飞机游戏含文档.zip J2ME飞机游戏含文档.zip J2ME飞机游戏含文档.zip J2ME飞机游戏含文档.zip J2ME飞机游戏含文档.zip J2ME飞机游戏含...
j2ME MMS彩信开发API .zip,j2ME MMS彩信开发API .zip,j2ME MMS彩信开发API .zip
J2ME手机游戏开发详解.iso J2ME手机游戏开发详解.iso
[J2ME编程].(Manning).J2ME.-.Java.in.small.things.(2002)
J2ME的3d开发教程.doc
J2ME无线移动游戏开发.iso J2ME无线移动游戏开发.iso
JAVA基于J2ME的手机游戏开发.zip
基于J2ME的手机游戏开发.pdf
JAVA基于J2ME的手机游戏开发.doc
[OpenGL编程指南(第四版)].(Ebook.-.Pdf.-.Java).O'Reilly.-.j2Me.In.A.Nutshell.pdf
J2ME 无线开发包 javax.wrieless.messaging 帮助文档 J2ME 无线开发包 javax.wrieless.messaging 帮助文档 J2ME 无线开发包 javax.wrieless.messaging 帮助文档
j2me开发大全源代码.zip
这是个人用j2me写的简单手机电话本,实现了以下功能: 1.查找 2.添加 3.删除 4.查看
基于J2ME的手机游戏开发.doc
其中包括: 基于j2me的手机游戏开发模式.pdf>> 移动设备中基于J2ME的2D游戏的开发.pdf>>