Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why won't my BACK BUTTON work?

 
ruffy me
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a short program to take me from a menu list to a form and back.
But my back button won't work. Can you tell me why? Thanks.

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class Testing extends MIDlet implements CommandListener {
private Command exitCommand = new Command("Exit", Command.EXIT, 2);
private Command goCommand = new Command("Go", Command.OK, 2);
private Command backCommand = new Command("Back", Command.BACK, 2);
private Display display;
private Alert resultAlert;
private List list;
public static final String[] items = {"Choice 1", "Choice 2", "Choice 3", "Choice 4"};
public Testing() {
display = Display.getDisplay(this);
list = new List("", List.IMPLICIT, items, null);
list.addCommand(exitCommand);
list.addCommand(goCommand);
list.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {
display.setCurrent(list);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
int len, i;
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
} else if (c == goCommand) {
Form resultSet = new Form("Results of Your Search");
String[] strings = {"Here is a page", "written by a sage"};
len = strings.length;
for (i=0; i<len; i++ ) {
resultSet.append(strings[i] + "\n");
}
resultSet.addCommand(backCommand);
display.setCurrent(resultSet);
}
}
}
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it needs to see a Chiropractor?

Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, because there is no code in the commandAction method to handle the user selecting the command


BACK

public static final int BACK

A navigation command that returns the user to the logically previous screen. The jump to the previous screen is not done automatically by the implementation but by the commandAction provided by the application. Note that the application defines the actual action since the strictly previous screen may not be logically correct.
Value 2 is assigned to BACK.

See Also:



Mark
 
ruffy me
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic