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.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class ListDemo1 extends MIDlet implements CommandListener {
private Display display;
private List exclusiveList;
Command CBack,CExit,CShow;
Form fC;
String[] stringArray = {
"Option A",
"Option B",
"Option C",
"Option D"
};
public ListDemo1() {
fC=new Form("Choice");
CBack=new Command("返回",Command.BACK,1);
CExit=new Command("退出",Command.EXIT,1);
CShow=new Command("show",Command.ITEM,1);
display = Display.getDisplay(this);
// these are the strings for the choices.
// the string elements will have no images
Image[] imageArray = null;
try {
Image icon=Image.createImage("/icon.PNG");
imageArray=new Image[4];
imageArray[0]=icon;
imageArray[1]=icon;
imageArray[2]=icon;
imageArray[3]=icon;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
exclusiveList = new List("Exclusive", Choice.EXCLUSIVE, stringArray,
imageArray);
exclusiveList.addCommand(CShow);
exclusiveList.addCommand(CExit);
exclusiveList.setCommandListener(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(exclusiveList);
}
public void commandAction(Command c, Displayable d) {
// TODO Auto-generated method stub
if(c==CBack){
System.out.println(CBack.getLabel());
display.setCurrent(exclusiveList);
}
if(c==CExit){
System.out.println(CExit.getLabel());
}
if(c==CShow){
int index=((List)d).getSelectedIndex();
System.out.println("选择了:"+index);
fC.append(stringArray[index]);
fC.addCommand(CBack);
fC.setCommandListener(this);
display.setCurrent(fC);
}
}
}
daima.rar_手机信息页面
版权申诉
91 浏览量
2022-09-19
18:19:12
上传
评论
收藏 2KB RAR 举报
小波思基
- 粉丝: 75
- 资源: 1万+
最新资源
- 前端技术栈: css和ES6
- 言西279-2024年7月1日
- Java项目-基于Springboot+Vue的私人健身与教练预约设计与实现源码+数据库脚本+部署视频+代码讲解视频+全套软件
- Java项目-基于Springboot+Vue的乒乓球预约管理的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件
- 哆咪付在线换钱系统.zip
- pycharm的优缺点及适用场景.zip
- Java项目-基于Springboot+Vue的留守儿童爱心网站的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件
- 流行的前端框架都有哪些?详细讲解React前端框架
- JSP宠物医院信息管理系统源码.rar
- Java项目-基于Springboot+Vue的家政服务管理平台的设计与实现(源码+数据库脚本+部署视频+代码讲解视频+全套软件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈