TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
- public class PhotoMIDlet extends MIDlet implements CommandListener
- {
- String list1[]={"1","2","3"};
- private Command okCommand=new Command("确定",Command.OK,1);
- private Command backCommand=new Command("返回",Command.BACK,1);
- private Command exitCommand=new Command("退出",Command.EXIT,1);
- private List list2=new List("Photo",List.EXCLUSIVE,list1,null);
- private Display display=null;
- private Form form=new Form("Photo");
- private Image img=null;
- public PhotoMIDlet(){
- list2.addCommand(okCommand);
- list2.addCommand(exitCommand);
- list2.addCommand(backCommand);
- list2.setCommandListener(this);
- form.addCommand(okCommand);
- form.addCommand(exitCommand);
- form.addCommand(backCommand);
- form.setCommandListener(this);
-
- }
- public void startApp(){
- if(display==null)
- display=Display.getDisplay(this);
- display.setCurrent(list2);
- }
- public void pauseApp(){
-
- }
- public void destroyApp(boolean unkown){
-
- }
- public void commandAction(Command cmd,Displayable dis){
- if(cmd==okCommand){
- int sIn=list2.getSelectedIndex();
- String str=(String)list2.getString(sIn);
- try{
- img=Image.createImage("/"+str+".png");
- }catch(Exception e){}
- form.append(img);
- display.setCurrent(form);
- }
- else if(cmd==backCommand){
- form.deleteAll();
- display.setCurrent(list2);
- }
- else if(cmd==exitCommand){
- destroyApp(true);
- notifyDestroyed();
- }
- }
- }
- [img]http://www.java3z.com/cwbwebhome/article/article7/img/6363we.jpg[/img]
复制代码
源码下载:http://203.93.208.26/kj/cwb/dir7/PhotoMIDlet.zip |
|