开发者

How to display a Dialog with progress spinner?

开发者 https://www.devze.com 2023-03-24 08:28 出处:网络
How to display a AlertDialog with a progress开发者_C百科bar spinner? When a button is pressed i want it to block the UI until the data is finished loading displaying a spinner and a message and title

How to display a AlertDialog with a progress开发者_C百科bar spinner?

When a button is pressed i want it to block the UI until the data is finished loading displaying a spinner and a message and title.

i know i will need to use an asyncTask for this but how do i go about displaying the dialog with progressbar spinner?


This should be all you need

ProgressDialog progressDialog = ProgressDialog.show(YourClassName.this, "", "Please wait");

Hope this helps


Also keep in mind that if you use ProgressDialog, you need to keep it reference for a later dismiss() and it'll crash if the orientation changes for example (because the dialog is destroyed and recreated)

So you need to update the reference, dismiss it when onPause() and recreate onResume() or use

...android:configChanges="orientation|keyboardHidden"></activity>

in the AndroidManifest.xml and handle the changes on your own


The simplest way to do this is use ProgressDialog. see the doc: http://developer.android.com/reference/android/app/ProgressDialog.html
Also, check out the dev guide for showing a dialog: http://developer.android.com/guide/topics/ui/dialogs.html They have a setiong about ProgressDialog.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号