How do you navigate between screens in J2ME? I would like to navigate to the
next screen using the default emulator in KToolbar. Here is a snippit of my
commandAction method:
public void commandAction(Command c, Displayable s) {
if (c == mMenuCommand)
{
mMenuForm = new Form("SampleMIDlet");
final String[] menuItems = { "Games" , "Calculator", "Alarm Clock" };
final List list = new List("Select a Item", List.IMPLICIT, menuItems, null);
final Command nextCommand = new Command("Next", Command.SCREEN, 0);
Command quitCommand = new Command("Quit", Command.SCREEN, 0);
list.addCommand(nextCommand);
list.addCommand(quitCommand);
list.setCommandListener(new CommandListener()
{
public void commandAction(Command c, Displayable s)
{
if (c == nextCommand || c == List.SELECT_COMMAND)
{
int index = list.getSelectedIndex();
System.out.println("Your selection: " + menuItems[index]);
// Move on to the next screen. Here, we just exit.
notifyDestroyed();
} else notifyDestroyed();
}
});
Display.getDisplay(this).setCurrent(list);
}
if (c == mExitCommand) notifyDestroyed();
}
Thanks!
Gilgantic