Android Programming Implementation dialog box encapsulation instance _android

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.