2009-12-16 147 views
1

我使用以下全局對話框在用戶退出應用程序並通知我的應用程序檢查某個任務後顯示一些消息。黑莓手機 - 全球屏幕修改?

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

我想添加這個對話框,我的應用程序標題,和一些消息(已經我給那個......)的標題,並刪除感嘆號或任何默認圖標已經給這個對話框。儘管在這個對話框中我不需要任何ICON。

如果你使用過它,有人可以給我建議嗎?

謝謝。感謝您能幫助我解決這個問題。

回答

4

有一個在Dialog類沒有標題,我會建議使用PopupScreen extention:
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); 
     } 
    } 
} 

修訂根據費爾南多評論

+0

哇!優秀的幫助。非常棒!我還有一個問題是,如果我想要顯示對話框並且如果設備屏幕已經處於關閉狀態使設備屏幕開啓,是否有可能? – Getsy 2009-12-16 17:59:25

+0

不客氣!單獨發佈關於顯示的問題,所以它將被搜索機器專用和索引:)! – 2009-12-16 19:30:53

+1

我不得不修改它... 代替: 屏幕屏幕=新GlobalDialog(標題,正文) 我用: GlobalDialog屏幕=新GlobalDialog(標題,正文) 否則我 – 2011-02-02 08:19:56