如何在Android中显示进度对话框?

发布于 2025-01-01 22:35:02 字数 1842 浏览 1 评论 0原文

当我调用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不乱于心 2025-01-08 22:35:02

将方法更改为:

Thread checkUpdate = new Thread() {
            public void run() {

                Status = cn.callWebService(url);
                getDetail(Status);
                handler.sendEmptyMessage(0);
            }
        };

change method to:

Thread checkUpdate = new Thread() {
            public void run() {

                Status = cn.callWebService(url);
                getDetail(Status);
                handler.sendEmptyMessage(0);
            }
        };
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文