1. There are two buttons in the dialog box
Builder = new alertdialog. builder (alertdialogactivity. this); builder. seticon (Android. r. drawable. btn_plus); builder. settitle ("btnplus"); builder. setmessage ("no? "); Builder. setpositivebutton ("OK", new dialoginterface. onclicklistener () {public void onclick (dialoginterface dialog, int which) {toast. maketext (alertdialogactivity. this, "you have selected the OK button", toast. length_short ). show () ;}}); builder. setnegativebutton ("cancel", new dialoginterface. onclicklistener () {public void onclick (dialoginterface dialog, int which) {toast. maketext (alertdialogactivity. this, "you have selected the cancel button", toast. length_short ). show () ;}}); builder. show ();}
2. Dialog Box with three buttons
Public void onclick (view v) {// todo auto-generated method stubnew alertdialog. builder (alertdialogactivity. this ). seticon (Android. r. drawable. btn_star ). settitle ("tip "). setmessage ("prompt content, three buttons "). setpositivebutton ("OK", new dialoginterface. onclicklistener () {public void onclick (dialoginterface Diener, int which) {// todo auto-generated method stubtoast. maketext (alertdialogactivity. this, "you have selected the OK button", toast. length_short ). show ();}}). setneutralbutton ("menu", new dialoginterface. onclicklistener () {public void onclick (dialoginterface Diener, int which) {// todo auto-generated method stubtoast. maketext (alertdialogactivity. this, "you have selected the detail button", toast. length_short ). show ();}}). setnegativebutton ("cancel", new dialoginterface. onclicklistener () {public void onclick (dialoginterface dialog, int which) {toast. maketext (alertdialogactivity. this, "you have selected the cancel button", toast. length_short ). show ();}}). show ();}
3. dialog box that can be entered
Public void onclick (view v) {// todo auto-generated method stublayoutinflater Inflater = layoutinflater. from (alertdialogactivity. this); final view textentryview = Inflater. inflate (R. layout. alert_dialog_text_entry, null); Final edittext usernameet = (edittext) textentryview. findviewbyid (R. id. username_value); Final edittext passwordet = (edittext) textentryview. findviewbyid (R. id. password_value); New alertdialog. builder (alertdialogactivity. this ). seticon (Android. r. drawable. btn_star ). settitle ("tip "). setview (textentryview ). setpositivebutton ("OK", new dialoginterface. onclicklistener () {public void onclick (dialoginterface dialog, int which) {toast. maketext (alertdialogactivity. this, "username =" + usernameet. gettext (). tostring () + "\ n Password =" + passwordet. gettext (). tostring (), toast. length_short ). show ();}}). setnegativebutton ("cancel", new dialoginterface. onclicklistener () {public void onclick (dialoginterface dialog, int which) {toast. maketext (alertdialogactivity. this, "you have selected the cancel button", toast. length_short ). show ();}}). show ();
4. progress bar dialog box
Progressdialog dialog = new progressdialog (alertdialogactivity. This); dialog. settitle ("processing... "); Dialog. setmessage (" Please wait... "); Dialog. Show ();