IT. Expert System.

Android Reference



Class ProgressBar

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback
    Direct Known Subclasses:

    public class ProgressBar
    extends View

    Visual indicator of progress in some operation. Displays a bar to the user representing how far the operation has progressed; the application can change the amount of progress (modifying the length of the bar) as it moves forward. 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.

    A progress bar can also be made indeterminate. In indeterminate mode, the progress bar shows a cyclic animation without an indication of progress. This mode is used by applications when the length of the task is unknown. The indeterminate progress bar can be either a spinning wheel or a horizontal bar.

    The following code example shows how a progress bar can be used from a worker thread to update the user interface to notify the user of progress:

     public class MyActivity extends Activity {
         private static final int PROGRESS = 0x1;
         private ProgressBar mProgress;
         private int mProgressStatus = 0;
         private Handler mHandler = new Handler();
         protected void onCreate(Bundle icicle) {
             mProgress = (ProgressBar) findViewById(;
             // Start lengthy operation in a background thread
             new Thread(new Runnable() {
                 public void run() {
                     while (mProgressStatus < 100) {
                         mProgressStatus = doWork();
                         // Update the progress bar
                Runnable() {
                             public void run() {

    To add a progress bar to a layout file, you can use the &lt;ProgressBar&gt; element. By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a horizontal progress bar, apply the Widget.ProgressBar.Horizontal style, like so:

         ... />

    If you will use the progress bar to show real progress, you must use the horizontal bar. You can then increment the progress with incrementProgressBy() or setProgress(). By default, the progress bar is full when it reaches 100. If necessary, you can adjust the maximum value (the value for a full bar) using the android:max attribute. Other attributes available are listed below.

    Another common style to apply to the progress bar is Widget.ProgressBar.Small, which shows a smaller version of the spinning wheel—useful when waiting for content to load. For example, you can insert this kind of progress bar into your default layout for a view that will be populated by some content fetched from the Internet—the spinning wheel appears immediately and when your application receives the content, it replaces the progress bar with the loaded content. For example:

         ... >
             android:layout_marginRight="5dp" />
             android:text="@string/loading" />

    Other progress bar styles provided by the system include:

    • Widget.ProgressBar.Horizontal
    • Widget.ProgressBar.Small
    • Widget.ProgressBar.Large
    • Widget.ProgressBar.Inverse
    • Widget.ProgressBar.Small.Inverse
    • Widget.ProgressBar.Large.Inverse

    The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary if your application uses a light colored theme (a white background).

    XML attributes

    See ProgressBar Attributes, View Attributes


Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)





Java Script








Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1162 / . Delta: 0.04475 с