ProgressDialog
public
class
ProgressDialog
extends AlertDialog
| java.lang.Object | |||
| ↳ | android.app.Dialog | ||
| ↳ | android.app.AlertDialog | ||
| ↳ | android.app.ProgressDialog | ||
This class was deprecated
in API level O.
Use a progress indicator such as ProgressBar inline inside of
an activity rather than using this modal dialog.
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 to max.
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 |
|---|
android.app.AlertDialog
|
android.content.DialogInterface
|
Public constructors | |
|---|---|
ProgressDialog(Context context)
Creates a Progress dialog. |
|
ProgressDialog(Context context, int theme)
Creates a Progress dialog. |
|
Public methods | |
|---|---|
int
|
getMax()
Gets the maximum allowed progress value. |
int
|
getProgress()
Gets the current progress. |
int
|
getSecondaryProgress()
Gets the current secondary progress. |
void
|
incrementProgressBy(int diff)
Increments the current progress value. |
void
|
incrementSecondaryProgressBy(int diff)
Increments the current secondary progress value. |
boolean
|
isIndeterminate()
Whether this ProgressDialog is in indeterminate mode. |
void
|
onStart()
Called when the dialog is starting. |
void
|
setIndeterminate(boolean indeterminate)
Change the indeterminate mode for this ProgressDialog. |
void
|
setIndeterminateDrawable(Drawable d)
Sets the drawable to be used to display the indeterminate progress value. |
void
|
setMax(int max)
Sets the maximum allowed progress value. |
void
|
setMessage(CharSequence message)
|
void
|
setProgress(int value)
Sets the current progress. |
void
|
setProgressDrawable(Drawable d)
Sets the drawable to be used to display the progress value. |
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)
Sets the style of this ProgressDialog, either |
void
|
setSecondaryProgress(int secondaryProgress)
Sets the secondary progress. |
static
ProgressDialog
|
show(Context context, CharSequence title, CharSequence message)
Creates and shows a ProgressDialog. |
static
ProgressDialog
|
show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, DialogInterface.OnCancelListener cancelListener)
Creates and shows a ProgressDialog. |
static
ProgressDialog
|
show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable)
Creates and shows a ProgressDialog. |
static
ProgressDialog
|
show(Context context, CharSequence title, CharSequence message, boolean indeterminate)
Creates and shows a ProgressDialog. |
Protected methods | |
|---|---|
void
|
onCreate(Bundle savedInstanceState)
Similar to |
void
|
onStop()
Called to tell you that you're stopping. |
Inherited methods | |
|---|---|
android.app.AlertDialog
| |
android.app.Dialog
| |
java.lang.Object
| |
android.content.DialogInterface
| |
android.view.Window.Callback
| |
android.view.KeyEvent.Callback
| |
android.view.View.OnCreateContextMenuListener
| |
Constants
STYLE_HORIZONTAL
int STYLE_HORIZONTAL
Creates a ProgressDialog with a horizontal progress bar.
Constant Value: 1 (0x00000001)
STYLE_SPINNER
int STYLE_SPINNER
Creates a ProgressDialog with a circular, spinning progress bar. This is the default.
Constant Value: 0 (0x00000000)
Public constructors
ProgressDialog
ProgressDialog (Context context)
Creates a Progress dialog.
| Parameters | |
|---|---|
context |
Context: the parent context
|
ProgressDialog
ProgressDialog (Context context, int theme)
Creates a Progress dialog.
| Parameters | |
|---|---|
context |
Context: the parent context |
theme |
int: the resource ID of the theme against which to inflate
this dialog, or 0 to use the parent
context's default alert dialog theme
|
Public methods
getMax
int getMax ()
Gets the maximum allowed progress value. The default value is 100.
| Returns | |
|---|---|
int |
the maximum value |
getProgress
int getProgress ()
Gets the current progress.
| Returns | |
|---|---|
int |
the current progress, a value between 0 and getMax()
|
getSecondaryProgress
int getSecondaryProgress ()
Gets the current secondary progress.
| Returns | |
|---|---|
int |
the current secondary progress, a value between 0 and getMax()
|
incrementProgressBy
void incrementProgressBy (int diff)
Increments the current progress value.
| Parameters | |
|---|---|
diff |
int: the amount by which the current progress will be incremented,
up to getMax()
|
incrementSecondaryProgressBy
void incrementSecondaryProgressBy (int diff)
Increments the current secondary progress value.
| Parameters | |
|---|---|
diff |
int: the amount by which the current secondary progress will be incremented,
up to getMax()
|
isIndeterminate
boolean isIndeterminate ()
Whether this ProgressDialog is in indeterminate mode.
| Returns | |
|---|---|
boolean |
true if the dialog is in indeterminate mode, false otherwise |
setIndeterminate
void setIndeterminate (boolean indeterminate)
Change the indeterminate mode for this ProgressDialog. In indeterminate mode, the progress is ignored and the dialog shows an infinite animation instead.
Note: A ProgressDialog with style STYLE_SPINNER
is always indeterminate and will ignore this setting.
| Parameters | |
|---|---|
indeterminate |
boolean: true to enable indeterminate mode, false otherwise |
See also:
setIndeterminateDrawable
void setIndeterminateDrawable (Drawable d)
Sets the drawable to be used to display the indeterminate progress value.
| Parameters | |
|---|---|
d |
Drawable: the drawable to be used |
setMax
void setMax (int max)
Sets the maximum allowed progress value.
| Parameters | |
|---|---|
max |
int |
setMessage
void setMessage (CharSequence message)
| Parameters | |
|---|---|
message |
CharSequence |
setProgress
void setProgress (int value)
Sets the current progress.
| Parameters | |
|---|---|
value |
int: the current progress, a value between 0 and getMax() |
See also:
setProgressDrawable
void setProgressDrawable (Drawable d)
Sets the drawable to be used to display the progress value.
| Parameters | |
|---|---|
d |
Drawable: the drawable to be used |
See also:
setProgressNumberFormat
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
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
void setProgressStyle (int style)
Sets the style of this ProgressDialog, either STYLE_SPINNER or
STYLE_HORIZONTAL. The default is STYLE_SPINNER.
Note: A ProgressDialog with style STYLE_SPINNER
is always indeterminate and will ignore the indeterminate setting.
| Parameters | |
|---|---|
style |
int: the style of this ProgressDialog, either STYLE_SPINNER or
STYLE_HORIZONTAL
|
setSecondaryProgress
void setSecondaryProgress (int secondaryProgress)
Sets the secondary progress.
| Parameters | |
|---|---|
secondaryProgress |
int: the current secondary progress, a value between 0 and
getMax() |
See also:
show
ProgressDialog show (Context context, CharSequence title, CharSequence message)
Creates and shows a ProgressDialog.
| Parameters | |
|---|---|
context |
Context: the parent context |
title |
CharSequence: the title text for the dialog's window |
message |
CharSequence: the text to be displayed in the dialog |
| Returns | |
|---|---|
ProgressDialog |
the ProgressDialog |
show
ProgressDialog show (Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, DialogInterface.OnCancelListener cancelListener)
Creates and shows a ProgressDialog.
| Parameters | |
|---|---|
context |
Context: the parent context |
title |
CharSequence: the title text for the dialog's window |
message |
CharSequence: the text to be displayed in the dialog |
indeterminate |
boolean: true if the dialog should be indeterminate, false otherwise |
cancelable |
boolean: true if the dialog is cancelable,
false otherwise |
cancelListener |
DialogInterface.OnCancelListener: the listener
to be invoked when the dialog is canceled |
| Returns | |
|---|---|
ProgressDialog |
the ProgressDialog |
show
ProgressDialog show (Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable)
Creates and shows a ProgressDialog.
| Parameters | |
|---|---|
context |
Context: the parent context |
title |
CharSequence: the title text for the dialog's window |
message |
CharSequence: the text to be displayed in the dialog |
indeterminate |
boolean: true if the dialog should be indeterminate, false otherwise |
cancelable |
boolean: true if the dialog is cancelable,
false otherwise |
| Returns | |
|---|---|
ProgressDialog |
the ProgressDialog |
show
ProgressDialog show (Context context, CharSequence title, CharSequence message, boolean indeterminate)
Creates and shows a ProgressDialog.
| Parameters | |
|---|---|
context |
Context: the parent context |
title |
CharSequence: the title text for the dialog's window |
message |
CharSequence: the text to be displayed in the dialog |
indeterminate |
boolean: true if the dialog should be indeterminate, false otherwise |
| Returns | |
|---|---|
ProgressDialog |
the ProgressDialog |
Protected methods
onCreate
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.
|
Interfaces
- ActionBar.OnMenuVisibilityListener
- ActionBar.OnNavigationListener
- ActionBar.TabListener
- AlarmManager.OnAlarmListener
- Application.ActivityLifecycleCallbacks
- Application.OnProvideAssistDataListener
- AppOpsManager.OnOpChangedListener
- DatePickerDialog.OnDateSetListener
- FragmentBreadCrumbs.OnBreadCrumbClickListener
- FragmentManager.BackStackEntry
- FragmentManager.OnBackStackChangedListener
- KeyguardManager.OnKeyguardExitResult
- LoaderManager.LoaderCallbacks
- Notification.Action.Extender
- Notification.Extender
- PendingIntent.OnFinished
- SearchManager.OnCancelListener
- SearchManager.OnDismissListener
- SharedElementCallback.OnSharedElementsReadyListener
- TimePickerDialog.OnTimeSetListener
- UiAutomation.AccessibilityEventFilter
- UiAutomation.OnAccessibilityEventListener
Classes
- ActionBar
- ActionBar.LayoutParams
- ActionBar.Tab
- Activity
- ActivityGroup
- ActivityManager
- ActivityManager.AppTask
- ActivityManager.MemoryInfo
- ActivityManager.ProcessErrorStateInfo
- ActivityManager.RecentTaskInfo
- ActivityManager.RunningAppProcessInfo
- ActivityManager.RunningServiceInfo
- ActivityManager.RunningTaskInfo
- ActivityManager.TaskDescription
- ActivityOptions
- AlarmManager
- AlarmManager.AlarmClockInfo
- AlertDialog
- AlertDialog.Builder
- AliasActivity
- Application
- ApplicationErrorReport
- ApplicationErrorReport.AnrInfo
- ApplicationErrorReport.BatteryInfo
- ApplicationErrorReport.CrashInfo
- ApplicationErrorReport.RunningServiceInfo
- AppOpsManager
- AutomaticZenRule
- DatePickerDialog
- Dialog
- DialogFragment
- DownloadManager
- DownloadManager.Query
- DownloadManager.Request
- ExpandableListActivity
- Fragment
- Fragment.SavedState
- FragmentBreadCrumbs
- FragmentContainer
- FragmentController
- FragmentHostCallback
- FragmentManager
- FragmentManager.FragmentLifecycleCallbacks
- FragmentManagerNonConfig
- FragmentTransaction
- Instrumentation
- Instrumentation.ActivityMonitor
- Instrumentation.ActivityResult
- IntentService
- KeyguardManager
- KeyguardManager.KeyguardDismissCallback
- KeyguardManager.KeyguardLock
- LauncherActivity
- LauncherActivity.IconResizer
- LauncherActivity.ListItem
- ListActivity
- ListFragment
- LoaderManager
- LocalActivityManager
- MediaRouteActionProvider
- MediaRouteButton
- NativeActivity
- Notification
- Notification.Action
- Notification.Action.Builder
- Notification.Action.WearableExtender
- Notification.BigPictureStyle
- Notification.BigTextStyle
- Notification.Builder
- Notification.CarExtender
- Notification.CarExtender.Builder
- Notification.CarExtender.UnreadConversation
- Notification.DecoratedCustomViewStyle
- Notification.DecoratedMediaCustomViewStyle
- Notification.InboxStyle
- Notification.MediaStyle
- Notification.MessagingStyle
- Notification.MessagingStyle.Message
- Notification.Style
- Notification.WearableExtender
- NotificationChannel
- NotificationChannelGroup
- NotificationManager
- NotificationManager.Policy
- PendingIntent
- PictureInPictureParams
- PictureInPictureParams.Builder
- Presentation
- ProgressDialog
- RemoteAction
- RemoteInput
- RemoteInput.Builder
- SearchableInfo
- SearchManager
- Service
- SharedElementCallback
- TabActivity
- TaskStackBuilder
- TimePickerDialog
- UiAutomation
- UiModeManager
- VoiceInteractor
- VoiceInteractor.AbortVoiceRequest
- VoiceInteractor.CommandRequest
- VoiceInteractor.CompleteVoiceRequest
- VoiceInteractor.ConfirmationRequest
- VoiceInteractor.PickOptionRequest
- VoiceInteractor.PickOptionRequest.Option
- VoiceInteractor.Prompt
- VoiceInteractor.Request
- WallpaperInfo
- WallpaperManager
Exceptions