“没有可显示的内容”在诺基亚 S40 上

发布于 2024-12-05 09:54:28 字数 2139 浏览 4 评论 0原文

我使用 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();

I coded a j2me application using LWUIT. It works fine on emulator as well as a symbian device. But when i tried to run it on a nokia s40 device,it showed up a "nothing to display" message. I tried displaying a splash screen, as prescribed in some forums. Still,the app never gets past the splash screen.

EDIT 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
        }

In this snippet,a blank screen is displayed on the device after the dialog/splash screen.
The form gets displayed when i remove the codes managing the RecordStore.
How do i fix this mess ?

EDIT 2
Code for registration()

        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();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

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

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

您需要在没有超时的情况下显示对话框(我会使用一个表单作为启动屏幕,没有理由使用对话框),然后打开一个线程(new Thread(...))来执行您想要的任何操作,然后当线程完成显示您的表单。

Change the splash.show() to splash.showModeless()

Regardless your code is incorrect since it assumes show() will display the dialog immediately which is not how most GUI frameworks work. Your method needs to complete and return control to LWUIT in order for the dialog to show. However, you read the RMS and then the code to show your form is unclear, when do you expect it to actually occur.

You need to show the dialog without a timeout (I would use a form for the splash screen there is no reason to use a dialog), then open a thread (new Thread(...)) to do whatever you want and then when the thread completes show your form.

嘦怹 2024-12-12 09:54:28

来自此博客,没有可显示的内容 问题是诺基亚 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();
           }
      }
    });

From this blog, The Nothing to display issue is standard Nokia S40 behavior for delayed calls to setCurrent() and the normal recommendation is to show a splash screen early on to avoid this prompt.

Also look this same related discussion.

Edit:

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();
           }
      }
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文