Most visited

Recently visited

Added in API level 1

ProgressDialog

public class ProgressDialog
extends AlertDialog

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


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.

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, DialogInterface.OnCancelListener cancelListener)
static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable)
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.

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.Window.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.View.OnCreateContextMenuListener

Constants

STYLE_HORIZONTAL

Added in API level 1
int STYLE_HORIZONTAL

Creates a ProgressDialog with a horizontal progress bar.

Constant Value: 1 (0x00000001)

STYLE_SPINNER

Added in API level 1
int STYLE_SPINNER

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

Constant Value: 0 (0x00000000)

Public constructors

ProgressDialog

Added in API level 1
ProgressDialog (Context context)

Parameters
context Context

ProgressDialog

Added in API level 1
ProgressDialog (Context context, 
                int theme)

Parameters
context Context
theme int

Public methods

getMax

Added in API level 1
int getMax ()

Returns
int

getProgress

Added in API level 1
int getProgress ()

Returns
int

getSecondaryProgress

Added in API level 1
int getSecondaryProgress ()

Returns
int

incrementProgressBy

Added in API level 1
void incrementProgressBy (int diff)

Parameters
diff int

incrementSecondaryProgressBy

Added in API level 1
void incrementSecondaryProgressBy (int diff)

Parameters
diff int

isIndeterminate

Added in API level 1
boolean isIndeterminate ()

Returns
boolean

onStart

Added in API level 1
void onStart ()

Called when the dialog is starting.

setIndeterminate

Added in API level 1
void setIndeterminate (boolean indeterminate)

Parameters
indeterminate boolean

setIndeterminateDrawable

Added in API level 1
void setIndeterminateDrawable (Drawable d)

Parameters
d Drawable

setMax

Added in API level 1
void setMax (int max)

Parameters
max int

setMessage

Added in API level 1
void setMessage (CharSequence message)

Parameters
message CharSequence

setProgress

Added in API level 1
void setProgress (int value)

Parameters
value int

setProgressDrawable

Added in API level 1
void setProgressDrawable (Drawable d)

Parameters
d Drawable

setProgressNumberFormat

Added in API level 11
void setProgressNumberFormat (String format)

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 String: A string passed to String.format(); use "%1d" for the current number and "%2d" for the maximum. If null, nothing will be shown.

setProgressPercentFormat

Added in API level 11
void setProgressPercentFormat (NumberFormat format)

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 NumberFormat: An instance of a NumberFormat to generate the percentage text. If null, nothing will be shown.

setProgressStyle

Added in API level 1
void setProgressStyle (int style)

Parameters
style int

setSecondaryProgress

Added in API level 1
void setSecondaryProgress (int secondaryProgress)

Parameters
secondaryProgress int

show

Added in API level 1
ProgressDialog show (Context context, 
                CharSequence title, 
                CharSequence message)

Parameters
context Context
title CharSequence
message CharSequence
Returns
ProgressDialog

show

Added in API level 1
ProgressDialog show (Context context, 
                CharSequence title, 
                CharSequence message, 
                boolean indeterminate, 
                boolean cancelable, 
                DialogInterface.OnCancelListener cancelListener)

Parameters
context Context
title CharSequence
message CharSequence
indeterminate boolean
cancelable boolean
cancelListener DialogInterface.OnCancelListener
Returns
ProgressDialog

show

Added in API level 1
ProgressDialog show (Context context, 
                CharSequence title, 
                CharSequence message, 
                boolean indeterminate, 
                boolean cancelable)

Parameters
context Context
title CharSequence
message CharSequence
indeterminate boolean
cancelable boolean
Returns
ProgressDialog

show

Added in API level 1
ProgressDialog show (Context context, 
                CharSequence title, 
                CharSequence message, 
                boolean indeterminate)

Parameters
context Context
title CharSequence
message CharSequence
indeterminate boolean
Returns
ProgressDialog

Protected methods

onCreate

Added in API level 1
void onCreate (Bundle savedInstanceState)

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

Parameters
savedInstanceState Bundle: If this dialog is being reinitialized 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.

onStop

Added in API level 1
void onStop ()

Called to tell you that you're stopping.

Hooray!