2011-07-20 57 views
1

任何人都可以讓我知道這是什麼窗口小部件?請參閱附件中的相關小部件。無法識別小部件?

當我點擊收到的消息時,它從消息應用程序啓動。

它將文本顯示爲應用程序名稱。我已經搜索了「消息傳遞」一詞,但沒有任何效果。

謝謝,enter image description here

回答

11

這不是Toast消息;這是一個AlertDialog

public class yourActivity extends Activity { 
    public final static int DIALOG_ERROR = 1; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     showDialog(DIALOG_ERROR); //this will call: onCreateDialog() 
    } 

    protected Dialog onCreateDialog(int id) { 
     Dialog dialog; 
    switch(id) { 
    case DIALOG_ERROR: 
     //create dialog 
     dialog = new AlertDialog.Builder(this).setMessage("Messaging").create(); 
     break; 
    default: 
     //create a default dialog 
     dialog = null; 
    } 
    return dialog; 
    } 

} 
+0

showDialog()從sdk 13開始已棄用 – auval

1

這是一個Toast消息與自定義ViewThis tutorial可以幫助你創建你自己的。

enter image description here

更多關於自定義敬酒的對象,檢查出this other tutorial

+2

誰可以downvoted請解釋爲什麼? – Phil

+0

Toasts不會顯示灰色/變暗背景....它當然是一個自定義對話框/警告框。我不是那個倒票的人。我也想要像你一樣回答...... –

+0

但是,如果你看看'Toast' [這裏](http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView),它集中在屏幕上,有角落,顯然是定製的。你甚至可以自定義背景顏色。 – Phil