Alert dialog box:
//Alert dialog Box Private voidAlertdialog () {Alertdialog.builder dialog=NewAlertdialog.builder (mainactivity. This); Dialog.settitle ("This is Dialog"); Dialog.setmessage ("Something Important"); Dialog.setcancelable (false); Dialog.setpositivebutton ("OK",NewDialoginterface.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) { //Confirm Logic } }); Dialog.setnegativebutton ("Cancel",NewDialoginterface.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) { //Canceling logic } }); Dialog.show (); }
Summary: Alert dialog box creation process
First, use Xxxdialog.builder to create a dialog object, accept an activity as a construction parameter
Second, use the Dialog.setxxx () method to set the appearance of the dialog box
Third, the realization function (positive and negative), and through the Dialog,show () display
Progress dialog box:
// progress Dialog private void ProgressDialog () {Progres Sdialog dialog = new progressdialog (mainactivity.this ); // progressdialog.builder dialog = new Progressdialog.builder (mainactivity.this); Dialog.settitle ("This is ProgressDialog" Loading ... "); Dialog.setcancelable ( true ); Dialog.show (); // dialog.dismiss () Close the dialog box }
Summary: Progress dialog box creation process
First, use the ProgressDialog class to create a dialog object, passing in a context object
Second, use the Dialog.setxxx () method to set the appearance of the dialog box
Third, through Dialog.show () Open the dialog box, through Dialog.dismiss () Close the dialog box
Original address: http://www.cnblogs.com/woider/p/5117728.html
Android Common dialog box demo