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 w
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 aProgressBar
in your layout.
It may be also usefull to consider the following answers:
While the answers here are informative, none really address the question.
(Thanks to Johnny S for the image of the ProgressDialog.)
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.
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.
ProgressBar
:
ProgressDialog
:
The ProgressBar
is a View
, ProgressDialog
is a Dialog
.