诺基亚 E72 上的 J2ME 中的 LWUIT 问题
好吧,我正在手机中开发一个要连接到我的 PC 的应用程序,问题是每次我向手机返回 URLRequest 时,它都会在屏幕上显示上一个表单,而不是实际的表单,例如这就是我的actionListener中的内容:
public void actionPerformed(ActionEvent ae) {
if (ae.getCommand() == guiaUtil.cSelecionar()) {
LoginRemote loginRemote = new LoginRemote();
try {
//This is the request, returns true or false, does not affect the form
loginRemote.login(tLogin.getText(), tPassword.getText());
} catch (Exception e) {
GuiaUtil.error(e);
return;
}
guiaUtil.mainApp().startMenu();
}
}
然后在“guiaUtil.mainApp().startMenu()”中我有这个
public void startMenu() {
if (itemsMenu == null) {
itemsMenu = new List();
itemsMenu.setWidth(320);
itemsMenu.addItem("Sincronize Spots");
itemsMenu.addItem("Find Spots");
itemsMenu.addItem("Work");
itemsMenu.setFocus(true);
this.addComponent(itemsMenu);
this.addCommandListener(this);
this.addCommand(guiaUtil.cSelect());
Form form = new Form();
form.addComponent(itemsMenu);
}
form.show();
}
无论如何,在请求返回后,它再次显示我的登录表单,而不是显示菜单列表
Well, I'm developing a app in my cellphone that is going to connect to my PC, the problem is that everytime that I return a URLRequest to the cellphone, it shows the previous Form on the screen and not de actual one, for example this is what goes in my actionListener:
public void actionPerformed(ActionEvent ae) {
if (ae.getCommand() == guiaUtil.cSelecionar()) {
LoginRemote loginRemote = new LoginRemote();
try {
//This is the request, returns true or false, does not affect the form
loginRemote.login(tLogin.getText(), tPassword.getText());
} catch (Exception e) {
GuiaUtil.error(e);
return;
}
guiaUtil.mainApp().startMenu();
}
}
Then in the "guiaUtil.mainApp().startMenu()" I have this
public void startMenu() {
if (itemsMenu == null) {
itemsMenu = new List();
itemsMenu.setWidth(320);
itemsMenu.addItem("Sincronize Spots");
itemsMenu.addItem("Find Spots");
itemsMenu.addItem("Work");
itemsMenu.setFocus(true);
this.addComponent(itemsMenu);
this.addCommandListener(this);
this.addCommand(guiaUtil.cSelect());
Form form = new Form();
form.addComponent(itemsMenu);
}
form.show();
}
Anyway, after the request returns, it shows my Login form again, instead of showing the Menu List
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许发生的情况是您遇到异常,用
GuiaUtil.error
处理它并从actionPerformed
返回,而不调用startMenu
。我会将 guiaUtil.mainApp().startMenu() 移动到 try/catch 块内。
Maybe what is going is that you are getting an exception, treating it with
GuiaUtil.error
and returning fromactionPerformed
without callingstartMenu
.I would move
guiaUtil.mainApp().startMenu()
inside the try/catch block.不确定
loginRemote.login(tLogin.getText(), tPassword.getText()); 中会发生什么情况
如果您访问网络,我会将该部分放在不同的线程中。当“远程登录”完成时,通过某种回调通知主线程,
然后您可以从 edt 显示 menuForm 。
Not sure what happens in
loginRemote.login(tLogin.getText(), tPassword.getText());
If you access the network, I would put that part in a different thread.Inform the main thread by some kind of callback when the "remote login" is done,
you can show the menuForm from the edt then.
您必须将以下代码放在 if 条件之外。
您有两个表单对象。一个在 if 内部,另一个在 if 外部。在循环内创建的对象将失去 if 内的范围。您正在 if 之外显示表单对象。这就是为什么菜单列表屏幕没有显示。
You have to put the following code outside the if condition.
You are having two form object. one inside if and another one outside of if. Object created inside the loop will loses the scope inside if. You are showing form object outside if. That's why, menu list screen was not displayed.