正文

List与图象载入2006-08-05 09:55:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/sword2008/17270.html

分享到:

import javax.microedition.midlet.*;import javax.microedition.lcdui.*; public class PhotoMIDlet extends MIDlet implements CommandListener{  String list1[]={"王","道","仁"};  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.setCommandListener(this);  form.addCommand(okCommand);  form.addCommand(exitCommand);  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(); }} }

阅读(3206) | 评论(1)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册