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(C ommand c, Displayable s) {
if (c == mMenuCommand)
{
mMenuForm = new Form("SampleMID let");
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.setCommand Listener(new CommandListener ()
{
public void commandAction(C ommand c, Displayable s)
{
if (c == nextCommand || c == List.SELECT_COM MAND)
{
int index = list.getSelecte dIndex();
System.out.prin tln("Your selection: " + menuItems[index]);
// Move on to the next screen. Here, we just exit.
notifyDestroyed ();
} else notifyDestroyed ();
}
});
Display.getDisp lay(this).setCu rrent(list);
}
if (c == mExitCommand) notifyDestroyed ();
}
Thanks!
Gilgantic