在LWUIT表格和LCDUI表格之间切换

Abd*_*air 5 lwuit lcdui java-me

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

bha*_*ath 5

我使用以下代码来显示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
}
Run Code Online (Sandbox Code Playgroud)