Android Common dialog box demo

Source: Internet
Author: User

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

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.