且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android中进行大量计算时如何显示加载屏幕?

更新时间:2021-12-29 10:01:05

尝试以这种方式处理

mProgressDialog = ProgressDialog.show(this, "Please wait","Long operation starts...", true);
        new Thread() {
            @Override
            public void run() {

               //Do long operation stuff here search stuff

                try {

                    // code runs in a thread
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mProgressDialog.dismiss();
                        }
                    });
                } catch (final Exception ex) {

                }
            }
        }.start();