gpt4 book ai didi

java-me - LWUIT 表单和 LCDUI 表单之间的切换

转载 作者:行者123 更新时间:2023-12-02 17:55:14 26 4
gpt4 key购买 nike

我已经构建了一个包含 Midlet 的 LWUIT UI 类。我基本上使用的是这个 midlet 中的主题。但我需要跳转到另一个包含一些 LCDUI 控件的 LCDUI 表单,并且我需要设置显示该 LCDUI 表单。那么是否可以从LWUIT表单跳转到LCDUI表单并设置显示LCDUI表单呢?如果可以的话怎么办?

最佳答案

我使用以下代码来显示 LWUIT 表单和 LCDUI 表单。请参阅示例代码。

com.sun.lwuit.Form lwuitForm;
protected void startApp() throws MIDletStateChangeException {
Display.init(this);
lwuitForm = new com.sun.lwuit.Form("LWUIT Form");
lwuitForm.addComponent(new TextField(""));

final MIDlet midlet = this;
final Command abtUsCmd = new Command("Next") {
public void actionPerformed(ActionEvent evt) {
javax.microedition.lcdui.Form frm = new javax.microedition.lcdui.Form("LCDUI Form");
StringItem item = new StringItem("Text", "Sample text");
frm.append(item);

final javax.microedition.lcdui.Command cmd = new javax.microedition.lcdui.Command("Back", javax.microedition.lcdui.Command.BACK, 0);
CommandListener cmdLis = new CommandListener() {

public void commandAction(javax.microedition.lcdui.Command c, Displayable d) {
if(c == cmd) {
Display.init(midlet);
lwuitForm.show(); // Show the LWUIT form again
}
}
};

frm.setCommandListener(cmdLis);
frm.addCommand(cmd);

javax.microedition.lcdui.Display.getDisplay(midlet).setCurrent(frm); // show the LCDUI Form
}
};
lwuitForm.addCommand(abtUsCmd);
lwuitForm.show(); // Show the LWUIT Form
}

关于java-me - LWUIT 表单和 LCDUI 表单之间的切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6639699/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com