【问题标题】:BlackBerry - Global screen modifictions?黑莓 - 全局屏幕修改?
【发布时间】:2009-12-16 10:48:09
【问题描述】:

在用户退出应用程序并通知我的应用程序检查某些任务后,我使用以下全局对话框显示一些消息。

synchronized( UiApplication.getEventLock() ) {
    UiEngine ui = Ui.getUiEngine();
    Screen screen = new Dialog(Dialog.D_OK, "My Message",
        Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), 
        Manager.VERTICAL_SCROLL);
    ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
}

我想将此对话框的标题添加为我的应用程序标题,并添加一些消息(我已经给出...)并删除感叹号或任何默认图标已提供给此对话框。虽然在这个对话框中我不想要任何图标。

如果你用过,有人可以推荐我吗?

谢谢。感谢您能帮我解决这个问题。

【问题讨论】:

    标签: user-interface blackberry dialog screen


    【解决方案1】:

    Dialog 类中没有标题,我建议使用PopupScreen 扩展:
    alt text http://img187.imageshack.us/img187/6245/9000.jpg

    class GlobalDialog extends PopupScreen implements FieldChangeListener {
        ButtonField mOKButton = new ButtonField("OK", ButtonField.CONSUME_CLICK
                | FIELD_HCENTER);
    
        public GlobalDialog(String title, String text) {
            super(new VerticalFieldManager());
            add(new LabelField(title));
            add(new SeparatorField(SeparatorField.LINE_HORIZONTAL));
            add(new LabelField(text, DrawStyle.HCENTER));
            mOKButton.setChangeListener(this);
            add(mOKButton);
        }
    
        public void fieldChanged(Field field, int context) {
            if (mOKButton == field)
                close();
        }
    }
    

    使用示例:

    class Scr extends MainScreen {
        public Scr() {
            synchronized (UiApplication.getEventLock()) {
                UiEngine ui = Ui.getUiEngine();
    
                String title = "Dialog Title";
                String text = "Lorem ipsum dolor sit amet, consectetur "
                        + "adipiscing elit. Donec venenatis " 
                        + "condimentum urna, non accumsan magna "
                        + "ultrices ut. Morbi fringilla ";
                GlobalDialog screen = new GlobalDialog(title, text);
    
                ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
            }
        }
    }
    

    根据费尔南多评论更新

    【讨论】:

    • 哇!极好的帮助。效果很好!我还有一个问题是,如果我想在设备屏幕已经处于关闭状态的情况下显示对话框并打开设备屏幕,这可能吗?
    • 不客气!发布有关显示的单独问题,以便搜索机器专用并对其进行索引:)!
    • 我不得不修改它...而不是:Screen screen = new GlobalDialog(title, text) 我使用:GlobalDialog screen = new GlobalDialog(title, text) 否则我
    • @Fernando:谢谢,已更新代码!但发誓我已经测试过了)))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-12
    • 2010-12-02
    相关资源
    最近更新 更多