This example describes the encapsulation of the Android Programming Implementation dialog box. Share to everyone for your reference, specific as follows:
/** * Dialog Box * * private static ProgressDialog Mprogressdialog; /** * Default Dialog box * Title, Content, two buttons * @param context * @param title * @param content * @param btnokstr is a null character, the button is not displayed (pay special attention) * @param BTNCANCELSTR is a null character, the button does not display * @param onClick/public static void Showdefaultdialog (context context,string title,string C Ontent, String btnokstr,string btncancelstr,onclicklistener onClick) {showdefaultdialog (context, title, content, Btno
KSTR, BTNCANCELSTR, OnClick, NULL); /** * Default dialog Box + Cancel Event * @param context * @param title * @param content * @param btnokstr * @param btncancelstr * @para M OnClick * @param oncancel */public static void Showdefaultdialog (context context,string title,string content, String Btnokstr,string btncancelstr, Onclicklistener onclick,oncancellistener oncancel) {Alertdialog.builder MBuilder = new
Alertdialog.builder (context);
if (title!= null) {Mbuilder.settitle (title);
} mbuilder.setmessage (content);
if (btnokstr = = null) Btnokstr = "OK"; if (BtncanCELSTR = = null) Btncancelstr = "Cancel";
if (!btnokstr.trim (). Equals ("")) Mbuilder.setpositivebutton (Btnokstr, OnClick);
if (!btncancelstr.trim (). Equals ("")) Mbuilder.setnegativebutton (Btncancelstr, OnClick);
if (OnCancel!= null) {Mbuilder.setoncancellistener (oncancel);
} mbuilder.show ();
public static void Showprogressdialog (context context,string Msg,boolean cancelable) {//Dismissprogressdialog ();
Mprogressdialog = new ProgressDialog (context);
Mprogressdialog.setmessage (msg);
Mprogressdialog.setcancelable (cancelable);
Mprogressdialog.show (); public static void Dismissprogressdialog () {if (Mprogressdialog!= null && mprogressdialog.isshowing ()) {m
Progressdialog.dismiss ();
Mprogressdialog = null;
}
}
I hope this article will help you with your Android programming.