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.