Android:progressdialog controls

Source: Internet
Author: User

ProgressDialog and Alertdialog are a bit similar, both can pop up a dialog box on the interface, can be able to block out other controls interactive ability. The difference is that ProgressDialog displays a progress bar in the dialog box, which is typically used to indicate that the current operation is time-consuming and allows the user to wait patiently. Its usage and alertdialog are similar, modify the code in the mainactivity as follows:

public class Mainactivity extends Activity implements Onclicklistener {

......

@Override

public void OnClick (View v) {

Switch (V.getid ()) {

Case R.id.button:

ProgressDialog ProgressDialog = new ProgressDialog

(Mainactivity.this);

Progressdialog.settitle ("This is ProgressDialog"); Progressdialog.setmessage ("Loading ..."); Progressdialog.setcancelable (TRUE); Progressdialog.show ();

Break

Default

Break

}

}

}

As you can see, this is also the first to build a ProgressDialog object, and then can also set the title, content, can be canceled and other properties, and finally by calling the show () method to display the ProgressDialog. Re-run the program, click the button, the effect is shown in 3.14. Note If False is passed in setcancelable (), indicating that ProgressDialog is not canceled by the back key, then you must be in control of the code, when the data load is completed, you have to call ProgressDialog Dismiss () method to close the dialog box, otherwise ProgressDialog will persist.

Figure 3.14

Android:progressdialog controls

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.