无法解除进度对话框

时间:2015-03-15 23:00:46

标签: java android parse-platform progressdialog

我从解析中获取数据时显示ProgressDialog。并且它应该在完成时解雇,但它没有。

private ProgressDialog progress;
mainAdapter.addOnQueryLoadListener(new ParseQueryAdapter.OnQueryLoadListener<ParseObject>(){
        @Override
        public void onLoading() {
            progress = ProgressDialog.show(this, "Tittle","Message", true);
        }
        @Override
        public void onLoaded(List<ParseObject> parseObjects, Exception e) {
            progress.dismiss();
        }
    });

我已尝试使用线程,我已使用progress.cancel()progress.hide()但由于某种原因ProgressDialog未关闭并停留在屏幕上,即使在dismiss命令。

1 个答案:

答案 0 :(得分:0)

progress = ProgressDialog.show(this, "Tittle","Message", true);

实际上是

    public static ProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate) {
    return show(context, title, message, indeterminate, false, null);
}

并调用此方法

    public static ProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate,
        boolean cancelable, OnCancelListener cancelListener) {
    ProgressDialog dialog = new ProgressDialog(context);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(cancelable);
    dialog.setOnCancelListener(cancelListener);
    dialog.show();
    return dialog;
}

所以cancelablefalse。尝试使用

progress = ProgressDialog.show(this, "Tittle","Message", true, true);

希望它有所帮助。