开发者

How to display a Dialog with progress spinner?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜