Android Message notification dialog box:
1) toast. maketext (login. This, R. String. login_dialog_note, Toast. length_long). Show ();
2) custom
Public void showtoast (){
Layoutinflater li = (layoutinflater) getsystemservice (context. layout_inflater_service );
View view = Li. Inflate (R. layout. Toast, null );
// Convert the layout file toast. xml into a view
Toast = new toast (this );
Toast. setview (View );
// Load the view to display the content of toast. xml.
Textview TV = (textview) view. findviewbyid (R. Id. TV1 );
TV. settext ("Toast show View content ");
// Modify the content in textview
Toast. setduration (toast. length_short );
// Set the display time, which is toast. length_long for a long time and toast. length_short for a short time. You cannot edit it by yourself.
Toast. Show ();
}
The content of toast. XML is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: Orientation = "vertical"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
>
<Imageview Android: src = "@ drawable/toast"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
/>
<Textview Android: Id = "@ + ID/TV1"
Android: text = ""
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
/>
</Linearlayout>
Android selection dialog box:
New alertdialog. Builder (dialogdemo. This)
. Seticon (R. drawable. icon32)
. Settitle (R. String. alert_dialog_two_buttons_msg)
. Setmessage (R. String. alert_dialog_two_buttons3_msg)
. Setpositivebutton (R. String. alert_dialog_yes,
New dialoginterface. onclicklistener (){
Public void onclick (dialoginterface dialog,
Int whichbutton ){
/* User clicked OK so do some stuff */
}
})
. Setnegativebutton (R. String. alert_dialog_no,
New dialoginterface. onclicklistener (){
Public void onclick (dialoginterface dialog,
Int whichbutton ){
/* User clicked OK so do some stuff */
}
})
. Create ();
Seticon uses the icon, settitle () sets the title, setmessage () sets the content of the displayed dialog box, setpositivebutton sets the first button, and the first attribute is the content of the set button, the second attribute is to set the event after clicking. setnegativebutton sets the second button as the first button.