【发布时间】:2016-06-18 08:07:12
【问题描述】:
我的片段中有一个链接,显示“单击以打开对话框”,单击它时会弹出一个警告对话框,显示“您要更改视图吗?”带有是和否符号。如果我单击“否”,则不会发生任何事情,并且对话框会按预期消失。但是,如果我单击是,如何调用函数来刷新我的视图,直到我的视图刷新显示进度对话框?到目前为止,这是我的代码,我不知道在哪里关闭进度对话框或确保刷新视图,有什么线索吗? :
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Are you sure you want to refresh your view?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//refreshview here ?
ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "",
"Loading. Please wait...", true);
progressDialog.show();
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(false);
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
【问题讨论】:
-
在
onClick的PositiveButton中添加dialog.dismiss();行
标签: android android-view android-alertdialog android-progressbar android-runonuithread