2011-07-20 143 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