在 J2me 应用程序中,我使用了带有 yes、no 命令的警报。如果用户单击是命令将显示窗体屏幕,如果单击否命令将显示文本框屏幕。但是代码不起作用。对于两个命令,只会显示文本框屏幕。
这是我的代码:
public Login(){
yes=new Command("Yes",Command.OK,1);
no=new Command("No",Command.CANCEL,1);
alert=new Alert("","Save The Changes?",null,AlertType.CONFIRMATION);
alert.setTimeout(Alert.FOREVER);
alert.addCommand(yes);
alert.addCommand(no);
textbox.setCommandListener(this);
alert.setCommanListener(this);
}
public void commandAction(Command command, Displayable displayable) {
if(displayable==textbox)
{
if(command==exit)
{
switchDisplayable(null,alert);
}
}
else if(displayable==alert)
{
if(command==no)
{
switchDisplayable(alert,getForm());
}
else if(command==yes)
{
switchDisplayable(alert,getTextbox());
}
}
}
我的错在哪里?