2

我使用 LWUIT 编写了一个 j2me 应用程序。它在模拟器和 symbian 设备上运行良好。但是当我尝试在诺基亚 s40 设备上运行它时,它显示了“无显示”消息。我尝试按照某些论坛的规定显示启动画面。尽管如此,该应用程序永远不会超过启动画面。

编辑 1

        Display.init(this);
        Resources r = Resources.open("/theme.res");
        UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));

        Dialog splash = new Dialog("Splash Screen");
        splash.setAutoDispose(true);
        splash.setTimeout(5000);
        splash.show();

        RecordStore rs = null;
        byte[] buffer = null;
        rs = RecordStore.openRecordStore("xxxxxx", true);
        if (rs.getNumRecords() > 0) {
            buffer = rs.getRecord(rs.getNumRecords());
            num = new String(buffer, 0, buffer.length);
            rs.closeRecordStore();
    offer(num);   // a method which displays main form
        } else {
            rs.closeRecordStore();
            registration("xxxxx"); //another method which displays the secondary form
        }

在此片段中,在对话框/启动屏幕之后的设备上显示一个空白屏幕。当我删除管理 RecordStore 的代码时,会显示该表单。我该如何解决这个烂摊子?

编辑 2 注册代码()

        Form f = new Form();
        f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        Image img = Image.createImage("logo.png");
        f.addComponent(new Label(img));
        Label lbl = new Label(msg);
        f.addComponent(lbl);
        f.addComponent(new Label("xxxxx"));
        final TextArea number = new TextArea(1, 10, TextArea.NUMERIC);
        f.addComponent(number);
        Button btn = new Button("Register");
        btn.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                //perform rms related activities and move onto offer()
            }
        });
        f.addComponent(btn);
        Button help = new Button("Help?");
        help.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                //display a help dialog
            }
        });
        f.addComponent(help);
        f.addCommandListener(this);
        f.show();
4

2 回答 2

4

更改splash.show()splash.showModeless()

无论您的代码是否不正确,因为它假定show()将立即显示对话框,这不是大多数 GUI 框架的工作方式。您的方法需要完成并将控制权返回给 LWUIT 才能显示对话框。但是,您阅读了 RMS,然后显示您的表单的代码不清楚,您希望它何时实际发生。

您需要在没有超时的情况下显示对话框(我会使用初始屏幕的表单,没有理由使用对话框),然后打开一个线程(新线程(...))来做任何你想做的事情,然后什么时候线程完成显示您的表格。

于 2011-09-22T08:27:44.920 回答
1

从此博客中, Nothing to display问题是诺基亚 S40 延迟呼叫的标准行为,setCurrent()正常建议是尽早显示初始屏幕以避免此提示。

也看看这个相同的相关讨论。

编辑:

Form splashscreen = new Form();
splashscreen.getStyle().setBgImage(imageName);
splashscreen.show()
Display.getInstance().callSerially(new Runnable() {
    public void run() {
      try {
           Thread.sleep(5000L);
           // do RMS related things here.

     } catch (InterruptedException ex) {
           ex.printStackTrace();
           }
      }
    });
于 2011-09-21T06:36:26.103 回答