当前位置: 代码迷 >> J2ME >> j2me按钮无效,各位大侠帮小弟我找找原因
  详细解决方案

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

热度:6234   发布时间:2013-02-25 21:35:15.0
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)   {