Hi guys!
I have a small problem using the commands, I have 2 forms in different classes and when I am in the second form I would like to be back in the first form....
this is the code:
I have 2 files: midlet and another file
public class midlet extends MIDlet implements CommandListener
{
private Display display;
private Form form;
private Command next,;
public void startApp()
{
display = Display.getDisplay(this);
Form form = new Form("");
next = new Command("Next",Command.ITEM,1);
form.addCommand(next);
form.setCommandListener(this);
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable displayable)
{
if(c==next)
OtherClass c = new OtherClass(display,form);
c.Method();
}
}
in OtherClass I did:
public class OtherClass
{
private Display display;
private Form form, form2;
private Command back;
public InsertNewUser(Display d, Form f)
{
display=d;
form=f;
}
private void Method()
{
form2 = new Form("");
back = new Command("back",Command.Back,0);
form2.addCommand(back);
display.setCurrent(form2);
form2.setCommandListener(new CommandListener( )
{
public void commandAction(Command c, Displayable d)
{
if (c==back)
{
display.setCurrent(form);
}
});
}
But when i press back the emulator doesn't cause any action....
Could someone help me please?
thanks
antonio

Reply With Quote

