What is the difference between Progressbar and progressDialog?

后端 未结 5 1695
一整个雨季
一整个雨季 2020-12-16 10:46

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

相关标签:
5条回答
  • 2020-12-16 11:04

    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:

    • https://stackoverflow.com/a/12559601/2482894
    • How to avoid ProgressDialog in Android
    0 讨论(0)
  • 2020-12-16 11:09

    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.)

    0 讨论(0)
  • 2020-12-16 11:10

    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.

    0 讨论(0)
  • 2020-12-16 11:11

    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.

    0 讨论(0)
  • 2020-12-16 11:20

    ProgressBar:

    ProgressDialog:

    The ProgressBar is a View, ProgressDialog is a Dialog.

    0 讨论(0)
提交回复
热议问题