良い一日。私は 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();
}