Android APIs
public class

ProgressDialog

extends AlertDialog
java.lang.Object
   ↳ android.app.Dialog
     ↳ android.app.AlertDialog
       ↳ android.app.ProgressDialog

Class Overview

A dialog showing a progress indicator and an optional text message or view. Only a text message or a view can be used at the same time.

The dialog can be made cancelable on back key press.

The progress range is 0..10000.

Summary

Constants
int STYLE_HORIZONTAL Creates a ProgressDialog with a horizontal progress bar.
int STYLE_SPINNER Creates a ProgressDialog with a circular, spinning progress bar.
[Expand]
Inherited Constants
From class android.app.AlertDialog
From interface android.content.DialogInterface
Public Constructors
ProgressDialog(Context context)
ProgressDialog(Context context, int theme)
Public Methods
int getMax()
int getProgress()
int getSecondaryProgress()
void incrementProgressBy(int diff)
void incrementSecondaryProgressBy(int diff)
boolean isIndeterminate()
void onStart()
Called when the dialog is starting.
void setIndeterminate(boolean indeterminate)
void setIndeterminateDrawable(Drawable d)
void setMax(int max)
void setMessage(CharSequence message)
void setProgress(int value)
void setProgressDrawable(Drawable d)
void setProgressNumberFormat(String format)
Change the format of the small text showing current and maximum units of progress.
void setProgressPercentFormat(NumberFormat format)
Change the format of the small text showing the percentage of progress.
void setProgressStyle(int style)
void setSecondaryProgress(int secondaryProgress)
static ProgressDialog show(Context context, CharSequence title, CharSequence message)
static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable)
static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, DialogInterface.OnCancelListener cancelListener)
static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate)
Protected Methods
void onCreate(Bundle savedInstanceState)
Similar to onCreate(Bundle), you should initialize your dialog in this method, including calling setContentView(View).
void onStop()
Called to tell you that you're stopping.
[Expand]
Inherited Methods
From class android.app.AlertDialog
From class android.app.Dialog
From class java.lang.Object
From interface android.content.DialogInterface
From interface android.view.KeyEvent.Callback
From interface android.view.View.OnCreateContextMenuListener
From interface android.view.Window.Callback

Constants

public static final int STYLE_HORIZONTAL

Added in API level 1

Creates a ProgressDialog with a horizontal progress bar.

Constant Value: 1 (0x00000001)

public static final int STYLE_SPINNER

Added in API level 1

Creates a ProgressDialog with a circular, spinning progress bar. This is the default.

Constant Value: 0 (0x00000000)

Public Constructors

public ProgressDialog (Context context)

Added in API level 1

public ProgressDialog (Context context, int theme)

Added in API level 1

Public Methods

public int getMax ()

Added in API level 1

public int getProgress ()

Added in API level 1

public int getSecondaryProgress ()

Added in API level 1

public void incrementProgressBy (int diff)

Added in API level 1

public void incrementSecondaryProgressBy (int diff)

Added in API level 1

public boolean isIndeterminate ()

Added in API level 1

public void onStart ()

Added in API level 1

Called when the dialog is starting.

public void setIndeterminate (boolean indeterminate)

Added in API level 1

public void setIndeterminateDrawable (Drawable d)

Added in API level 1

public void setMax (int max)

Added in API level 1

public void setMessage (CharSequence message)

Added in API level 1

public void setProgress (int value)

Added in API level 1

public void setProgressDrawable (Drawable d)

Added in API level 1

public void setProgressNumberFormat (String format)

Added in API level 11

Change the format of the small text showing current and maximum units of progress. The default is "%1d/%2d". Should not be called during the number is progressing.

Parameters
format A string passed to String.format(); use "%1d" for the current number and "%2d" for the maximum. If null, nothing will be shown.

public void setProgressPercentFormat (NumberFormat format)

Added in API level 11

Change the format of the small text showing the percentage of progress. The default is NumberFormat.getPercentageInstnace(). Should not be called during the number is progressing.

Parameters
format An instance of a NumberFormat to generate the percentage text. If null, nothing will be shown.

public void setProgressStyle (int style)

Added in API level 1

public void setSecondaryProgress (int secondaryProgress)

Added in API level 1

public static ProgressDialog show (Context context, CharSequence title, CharSequence message)

Added in API level 1

public static ProgressDialog show (Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable)

Added in API level 1

public static ProgressDialog show (Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, DialogInterface.OnCancelListener cancelListener)

Added in API level 1

public static ProgressDialog show (Context context, CharSequence title, CharSequence message, boolean indeterminate)

Added in API level 1

Protected Methods

protected void onCreate (Bundle savedInstanceState)

Added in API level 1

Similar to onCreate(Bundle), you should initialize your dialog in this method, including calling setContentView(View).

Parameters
savedInstanceState If this dialog is being reinitalized after a the hosting activity was previously shut down, holds the result from the most recent call to onSaveInstanceState(), or null if this is the first time.

protected void onStop ()

Added in API level 1

Called to tell you that you're stopping.