26

I have searched everywhere and read the official doc of Google. But I still don't see the difference between them.

When should we use ProgressBar and when should we use ProgressDialog?

Ahmad
  • 69,608
  • 17
  • 111
  • 137
Mathieu
  • 1,491
  • 5
  • 17
  • 37

5 Answers5

38

ProgressBar:

ProgressDialog:

The ProgressBar is a View, ProgressDialog is a Dialog.

Ahmad
  • 69,608
  • 17
  • 111
  • 137
31

While the answers here are informative, none really address the question.

  • Use a ProgressDialog when you want to prevent the user from interacting with the application while waiting. The Dialog aspect freezes the user from doing anything until it is dismissed. Note how the UI behind the ProgressDialog is grayed-out and inaccessible.

ProgressDialog example

  • Use a ProgressBar to indicate that something in your app is still waiting (loading, thinking, etc.) while the user may still interact with other parts. In this image, the user can still fill out forms while waiting for the gps to respond.

ProgressBar Example

(Thanks to Johnny S for the image of the ProgressDialog.)

SMBiggs
  • 11,034
  • 6
  • 68
  • 83
  • also for pDialog you can't use the back arrow to dismiss it,while you can use it with pBar – monim Dec 01 '15 at 17:50
24

ProgressBar is a View (like TextView, ImageView, Button, etc..), which can be used in your layout to show some progress.

ProgressDialog is a Dialog with 'built-in' ProgressBar. Dialogs can be used to make user wait while something is being computed. ProgressDialog makes it easier to show progress of your computation in dialog.

Berťák
  • 7,143
  • 2
  • 29
  • 38
4

In addition to the differences pointed out in the rest of answers, you should take into account the following recommendation from Dialogs @ Android Developer:

Avoid ProgressDialog

Android includes another dialog class called ProgressDialog that shows a dialog with a progress bar. However, if you need to indicate loading or indeterminate progress, you should instead follow the design guidelines for Progress & Activity and use a ProgressBar in your layout.

It may be also usefull to consider the following answers:

Community
  • 1
  • 1
leo9r
  • 2,037
  • 26
  • 30
1

When your iterations is countable (doing operations in loop, executing code x times etc.) use ProgressBar, if task is not countable status (like invoking web service) use ProgressDialog

From the android documentation

ProgressBar: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.

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.

hkutluay
  • 6,794
  • 2
  • 33
  • 53