单击后退按钮给出非法状态异常
在我的应用程序中,当我单击时,我会显示一个对话框。当我在该对话框中按“是”时,它给了我非法状态异常。但我想返回到上一个屏幕。如果我单击菜单并单击关闭,则会返回到上一个屏幕。以下是我的代码:
public boolean keyDown(int keycode, int time) {
if (Keypad.KEY_ESCAPE == Keypad.key(keycode)) {
int result = Dialog.ask(Dialog.D_YES_NO, "Do you want to edit the list?");
if (result == Dialog.YES)
{
try
{
UiApplication.getUiApplication().popScreen(this);
}
catch (Exception e)
{
e.printStackTrace();
}
// onClose();
}
else
{
return true;
}
} // end if
return false;
}
请帮忙..
In my application, when i am clicking i showing a dialog. and when i am pressing yes in that Dialog, it is giving me the illegal state exception. But i want to go back in the previous screen. If i am clicking menu and clicking close, then it is going back to the previous screen. Below is my code:
public boolean keyDown(int keycode, int time) {
if (Keypad.KEY_ESCAPE == Keypad.key(keycode)) {
int result = Dialog.ask(Dialog.D_YES_NO, "Do you want to edit the list?");
if (result == Dialog.YES)
{
try
{
UiApplication.getUiApplication().popScreen(this);
}
catch (Exception e)
{
e.printStackTrace();
}
// onClose();
}
else
{
return true;
}
} // end if
return false;
}
Please help..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您单击设备中的后退按钮时,将调用默认的 onclose() 方法。所以,尝试这样做;
这是更好的方法;如果你像上面那样使用,那么你可能会遇到一个问题;那是:
试试这个;
When you are clicking the back button in the device then default onclose() method is called. So, try to do like this;
This is the better way; If you use like the above one then you may get one problem; That is:
Try this one;