如何在Android中显示进度对话框?
当我调用 Web 服务并调用 Web 服务结束对话框自动关闭时,我想在我的活动中显示进度对话框,任何人都可以知道如何执行此操作,我想要一些示例。 提前致谢。
这是我的代码,但它工作不正常,
final ProgressDialog dialog = ProgressDialog.show(
RouteServicing.this, "", "Loading. Please wait...", true);
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
dialog.dismiss();
}
};
Thread checkUpdate = new Thread() {
public void run() {
Status = cn.callWebService(url);
getDetail(Status);
//handler.sendEmptyMessage(0);
dialog.dismiss();
}
};
checkUpdate.start();
它向我显示了这个错误
02-02 16:06:53.219: E/WindowManager(1127): android.view.WindowLeaked: Activity com.palewar.coinop.RouteServicing has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405db660 that was originally added here
02-02 16:06:53.219: E/WindowManager(1127): at android.view.ViewRoot.<init>(ViewRoot.java:272)
02-02 16:06:53.219: E/WindowManager(1127): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
02-02 16:06:53.219: E/WindowManager(1127): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-02 16:06:53.219: E/WindowManager(1127): at android.view.Window$LocalWindowManager.addView(Window.java:424)
02-02 16:06:53.219: E/WindowManager(1127): at android.app.Dialog.show(Dialog.java:241)
02-02 16:06:53.219: E/WindowManager(1127): at android.app.ProgressDialog.show(ProgressDialog.java:107)
02-02 16:06:53.219: E/WindowManager(1127): at android.app.ProgressDialog.show(ProgressDialog.java:90)
02-02 16:06:53.219: E/WindowManager(1127): at com.palewar.coinop.RouteServicing.onClick(RouteServicing.java:243)
i want to display progressDialog in my activity when im call webservices and call to webservices ends Dialog dismiss automatically can any know how to do this and i want some sample for it .
Thankx in advance .
here is my code but it not working fine
final ProgressDialog dialog = ProgressDialog.show(
RouteServicing.this, "", "Loading. Please wait...", true);
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
dialog.dismiss();
}
};
Thread checkUpdate = new Thread() {
public void run() {
Status = cn.callWebService(url);
getDetail(Status);
//handler.sendEmptyMessage(0);
dialog.dismiss();
}
};
checkUpdate.start();
it shows me this error
02-02 16:06:53.219: E/WindowManager(1127): android.view.WindowLeaked: Activity com.palewar.coinop.RouteServicing has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405db660 that was originally added here
02-02 16:06:53.219: E/WindowManager(1127): at android.view.ViewRoot.<init>(ViewRoot.java:272)
02-02 16:06:53.219: E/WindowManager(1127): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
02-02 16:06:53.219: E/WindowManager(1127): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-02 16:06:53.219: E/WindowManager(1127): at android.view.Window$LocalWindowManager.addView(Window.java:424)
02-02 16:06:53.219: E/WindowManager(1127): at android.app.Dialog.show(Dialog.java:241)
02-02 16:06:53.219: E/WindowManager(1127): at android.app.ProgressDialog.show(ProgressDialog.java:107)
02-02 16:06:53.219: E/WindowManager(1127): at android.app.ProgressDialog.show(ProgressDialog.java:90)
02-02 16:06:53.219: E/WindowManager(1127): at com.palewar.coinop.RouteServicing.onClick(RouteServicing.java:243)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将方法更改为:
change method to: