Android ProgressDialog不会解雇

时间:2014-06-11 20:55:03

标签: android android-asynctask progressdialog

我正在尝试编写代码,例如,可以在5秒后显示AlertDialog消息,在这5秒内我想显示ProgressDialog

我编写了代码但ProgressDialog没有解雇。 这是源代码:

ringProgressDialog = ProgressDialog.show(CameraPreview.this,
        "Please wait ...", "Downloading Image ...", true);

ringProgressDialog.setCancelable(false);
ringProgressDialog.hide();

AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {

    @Override
    protected void onPreExecute() {

        ringProgressDialog.show();
    }

    @Override
    protected Void doInBackground(Void... arg0) {
        try {
            diaBox1.show();
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        if (ringProgressDialog != null) {
            ringProgressDialog.dismiss();
            // b.setEnabled(true);
        }
    }

};
task.execute((Void[]) null);

0 个答案:

没有答案