Use of progressdialog and progressbar in Android

Source: Internet
Author: User

There are two ways to display progress bars in Android: progressbar and progressdialog.

 

Progressdialog is displayed in the form of opening a new window. It can have many attributes:

 

1) create a common progressdialog (without progressbar) required parameters

    • Context: Specify the container of the current Dialog
    • Title: Dialog Box title
    • Message: information displayed by the subject in the dialog box
    • Indeterminate: uncertainty attribute, which has no practical significance for the default runner mode of progressdailog.SetTrue. It only applies to the dialog with progressbar.If this attribute is set to false, the progress of the progress bar can be updated in real time.

2) the following two are optional parameters.

    • Cancelable: Add a button that can be used to force the cancel current dialog to exit.
    • Cancellistner: The current dialog is executed after being forcibly canceled. It is usually used to clear unfinished tasks.

InProgramYou can use:

Progressdialog Pd = progressdialog. Show (ex04_17.this, "hello", "Hello world! ");

Or

Pd = new progressdialog (ex04_17.this );

PD. setindeterminate (false );

PD. setprogressstyle (progressdialog. style_horizontal );

PD. Show ();

Create a progressdialog, but I don't know whether the progress bar can be set in the first method (I didn't find a method anyway ). Pass

PD. setprogress (intcounter );

Update progress bar

 

Progressbar is embedded in the activity for display. Its Attributes and usage are similar to progressdialog.

 

Both of them can be used to set attributes in XML, and you can set the attribute to gone first. When the attribute needs to be displayed, set the attribute to visible.

 

Of course, both of them usually need handler to update the progress bar.

 

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.