import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class listtest extends midlet implements commandlistener{
private list alist;
private command exitcommand;
private command okcommand;
private display adisplay;
private alert analert;
public listtest(){
analert=new alert("selected","you have choose a fruit",null,alerttype.info);
alist=new list("fruit",choice.multiple);
exitcommand=new command("exit",command.exit,1);
okcommand=new command("ok",command.ok,1);
alist.append("apple",null);
alist.append("orange",null);
alist.append("banana",null);
alist.addcommand(exitcommand);
alist.addcommand(okcommand);
alist.setcommandlistener(this);
}
public void startapp(){
adisplay=display.getdisplay(this);
adisplay.setcurrent(alist);
}
public void pauseapp(){
}
public void destroyapp(boolean unconditional){
}
public void commandaction(command c,displayable d){
// use the i get the selected list element
//int i =alist.getselectedindex();
if(c==exitcommand){
destroyapp(false);
notifydestroyed();
}
else {
//display different information when diffenent element
//have been selected
/*if(i==0){
analert.setstring("you have choosed apple!");
adisplay.setcurrent(analert,alist);
}
if(i==1){
analert.setstring("you have choosed orange!");
adisplay.setcurrent(analert,alist);
}
if(i==2){
analert.setstring("you have choosed banana!");
adisplay.setcurrent(analert,alist);
}*/
string s=" ";
for(int i=0;i<alist.size();i++){
boolean selected=alist.isselected(i);
if(selected&&i==0){
s+="apple ";
}
if(selected&&i==1){
s+="orange ";
}
if(selected&&i==2){
s+="banana ";
}
}
analert.setstring("you have selected"+s);
analert.settimeout(alert.forever);
adisplay.setcurrent(analert,alist);
}
}
}
我的J2ME编程联系(1)——List-JSP教程,J2ME开发
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 我的J2ME编程联系(1)——List-JSP教程,J2ME开发
相关推荐
-      J2ME中的时间处理方法
-      J2ME播放声音流程简介
-      J2ME开发之手机键盘使用注意问题
-      J2ME 记录管理存储
-      MVC模式在j2me项目中的应用(二)
-      MVC模式在j2me项目中的应用(一)
-      J2ME中使用记录存储系统(RMS)存储信息
-      J2ME与MIDP开发(1)