1

再会。我是 J2ME 新手,刚开始构建应用程序。我面临的挑战是,我有一个 MIDlet 和不同类的多个页面(表单),并返回到以前的页面,尤其是 midlet 是一个问题。从 AirtimeTopUp 页面,我正在尝试返回 SignedIn。但我不断收到错误,我对下一步该做什么有点困惑。

  public class AirtimeTopUp extends Form implements CommandListener {

  private Command mNextCommand;
  private Command mBackCommand;
  private SignedIn dis;
  private SignedIn startUp;
  private List list;
  private ChoiceGroup choiceGroup;
  private Display displayMngr = null;
  MyPiDONumber form3 = null;

  public AirtimeTopUp(SignedIn dis) {

      super("Top Up");
      this.dis = dis;
      choiceGroup = new ChoiceGroup(null, Choice.EXCLUSIVE);
      choiceGroup.append("My PiDO Number", null);
      choiceGroup.append("Other Number", null);
      mNextCommand = new Command("Continue", Command.SCREEN, 1);
      mBackCommand = new Command("Back", Command.BACK, 2);
      append(choiceGroup);
      this.setCommandListener(this);
      addCommand(mNextCommand);
      addCommand(mBackCommand);
      Display.getDisplay(dis).setCurrent(this);
  }

  public void commandAction(Command c, Displayable d) {
      if (c == mNextCommand) {
          int index = choiceGroup.getSelectedIndex();
          if (choiceGroup.getString(index).startsWith("My")) {
               Display.getDisplay(dis).setCurrent(new MyPiDONumber(dis));
          } else if (choiceGroup.getString(index).startsWith("Other Number")) {

            }
      } else {
          if (c == mBackCommand) {
              Display.getDisplay(dis).setCurrent(new SignedIn(dis));
          }
      }
  }

}

这是我的 MIDlet 类:

 public class SignedIn extends MIDlet implements CommandListener {
   private List mList;
   private Command mExitCommand, mNextCommand;
   private Display displayMngr = null;
   private AirtimeTopUp airtime = null;


public SignedIn(){
  String[] stringElements = { "Airtime TopUp", "Transfer", "Cashout", "Balance", "Pay Bills", "Mini Statement", "Account Settings", "PayCom Contacts", "cCare" };
  //Image[] imageElements = { loadImage("airplane.png"), loadImage("car.png"), loadImage("hotel.png") };
  mList = new List("Welcome!", List.IMPLICIT, stringElements, null);

  mNextCommand = new Command("Next", Command.SCREEN, 0);
  mExitCommand = new Command("Exit", Command.EXIT, 0);
  mList.addCommand(mNextCommand);
  mList.addCommand(mExitCommand);
  mList.setCommandListener(this);
}

public void startApp() {
    Display.getDisplay(this).setCurrent(mList);
}

public void commandAction(Command c, Displayable s) {
    if (c == mNextCommand || c == List.SELECT_COMMAND) {
        int index = mList.getSelectedIndex();
        if(mList.getString(index).startsWith("Airtime")){
            new AirtimeTopUp(this);
        }
        else if(mList.getString(index).startsWith("Transfer")){
            Alert alert = new Alert("Your selection", "You chose " + mList.getString(index) + ".", null, AlertType.INFO);
            alert.setTimeout(Alert.FOREVER);
            displayMngr.setCurrent(alert, mList);
        }
    }
    else if (c == mExitCommand)
        notifyDestroyed();
}
4

0 回答 0