首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2ME开发 >

j2me按钮无效,各位大侠帮小弟我找找原因

2012-01-24 
j2me按钮无效,各位大侠帮我找找原因我很郁闷...IndexForm,MainList这两个界面都正常的,但到了第三级界面Pe

j2me按钮无效,各位大侠帮我找找原因
我很郁闷...IndexForm   ,MainList   这两个界面都正常的,但到了第三级界面
PersonList,AddForm的按钮就不行了.
下面是RMSMain的代码.

package   personList;

import   javax.microedition.lcdui.Command;
import   javax.microedition.lcdui.CommandListener;
import   javax.microedition.lcdui.Display;
import   javax.microedition.lcdui.Displayable;
import   javax.microedition.midlet.MIDlet;
import   javax.microedition.midlet.MIDletStateChangeException;

public   class   RMSMain   extends   MIDlet   implements   CommandListener{

IndexForm   indexform;                        

MainList   mainlist;

PersonList   personlist;

AddForm   addform;

DetailForm   detailform;

PersonAction   personaction;

Display   display;

public   RMSMain()   {

indexform   =   new   IndexForm( "电话簿,欢迎您 ");
mainlist   =   new   MainList();
personlist   =   new   PersonList();

addform   =   new   AddForm( "添加联系人 ");

detailform   =   new   DetailForm( "联系人信息 ");

personaction   =   new   PersonAction();

indexform.setCommandListener(this);
mainlist.setCommandListener(this);
personlist.setCommandListener(this);
addform.setCommandListener(this);
detailform.setCommandListener(this);

}

protected   void   destroyApp(boolean   b)   throws   MIDletStateChangeException   {

}

protected   void   pauseApp()   {

}

protected   void   startApp()   throws   MIDletStateChangeException   {
display   =   Display.getDisplay(this);
display.setCurrent(indexform);
}

public   void   commandAction(Command   c,   Displayable   d)   {
if   (c   ==   indexform.cmdOk)   {
display.setCurrent(mainlist);
}   else   if   (   d   instanceof   MainList)   {
if   (   c   ==   mainlist.cmdOk)   {
int   i   =   mainlist.getSelectedIndex();
System.out.print(i);
switch(i)   {
case   0:
System.out.println( "0 ");
personlist   =   personaction.readAll();
display.setCurrent(personlist);
break;
case   1:
System.out.print( "1 ");
display.setCurrent(addform);
break;
case   2:
break;
}
}   else   if   (   c   ==   mainlist.cmdBack)   {
display.setCurrent(indexform);
}
}   else   if   (d   instanceof   PersonList)   {
if   (c   ==   personlist.cmdOk)   {
System.out.print( "personlist.cmdOk ");
int   i   =   personlist.getSelectedIndex();
detailform   =   detailform.ShowDetailPerson(i,   personaction.getVector());
display.setCurrent(detailform);
}   else   if   (c   ==   personlist.cmdBack)   {
display.setCurrent(mainlist);
}
}   else   if   (d   instanceof   AddForm)   {
if   (c   ==   addform.cmdOk)   {


personaction.add();
personlist   =   personaction.readAll();
display.setCurrent(personlist);
}else   if   (c   ==   addform.cmdBack)   {
display.setCurrent(mainlist);
}
}
}
}


[解决办法]
你把每个页面的正厅分开写吧!
[解决办法]
indexform = new IndexForm( "电话簿,欢迎您 ");
mainlist = new MainList();

personlist = new PersonList();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~这里的问题吧,PersonList有2个构造方法,这用的是第一个构造方法,都没有cmdBack = new Command( "返回 ", Command.BACK, 0);cmdOk = new Command( "确定 ", Command.OK, 0);


this.addCommand(cmdBack);
this.addCommand(cmdOk);

addform = new AddForm( "添加联系人 ");

detailform = new DetailForm( "联系人信息 ");

热点排行