Class ProgressBar

java.lang.Object
icyllis.modernui.view.View
icyllis.modernui.widget.ProgressBar
All Implemented Interfaces:
Drawable.Callback
Direct Known Subclasses:
AbsSeekBar

public class ProgressBar extends View

A user interface element that indicates the progress of an operation. Progress bar supports two modes to represent progress: determinate, and indeterminate. For a visual overview of the difference between determinate and indeterminate progress modes, see Progress invalid input: '&' activity. Display progress bars to a user in a non-interruptive way. Show the progress bar in your app's user interface or in a notification instead of within a dialog.

Indeterminate Progress

Use indeterminate mode for the progress bar when you do not know how long an operation will take. Indeterminate mode shows a cyclic animation without a specific amount of progress indicated. There is no disabled state in indeterminate mode. The following example shows an indeterminate progress bar:


 var progressBar = new ProgressBar;
 progressBar.setIndeterminate(true);
 parent.addView(progressBar, WRAP_CONTENT, WRAP_CONTENT);
 

Determinate Progress

Use determinate mode for the progress bar when you want to show that a specific quantity of progress has occurred. For example, the percent remaining of a file being retrieved, the amount records in a batch written to database, or the percent remaining of an audio file that is playing.

To indicate determinate progress, you set the amount of progress. The following example shows a determinate progress bar that is 25% complete:


 var progressBar = new ProgressBar;
 progressBar.setProgress(2500);
 parent.addView(progressBar, WRAP_CONTENT, WRAP_CONTENT);
 
You can update the percentage of progress displayed by using the setProgress(int) method, or by calling incrementProgressBy(int) to increase the current progress completed by a specified amount. By default, the progress bar is full when the progress value reaches 10000. You can adjust this default by setting the modernui:max attribute.

There is also a secondary progress displayable on a progress bar which is useful for displaying intermediate progress, such as the buffer level during a streaming playback progress bar. With a linear type progress bar and in determinate mode, you can set a secondary progress by using the setSecondaryProgress(int) method, or by calling incrementSecondaryProgressBy(int).

Other progress bar styles provided by the system include:

The horizontal and vertical styles provide a the linear type progress bar. The others (and the default) provide a circular type progress bar.