我在代码下面有一个进度对话框:
ProgressDialog pDialog = new ProgressDialog(activity);
pDialog.setMessage("Please wait ...");
pDialog.setIndeterminate(false);
pDialog.setMax(100);
pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pDialog.setCancelable(true);
pDialog.setButton(ProgressDialog.BUTTON_NEUTRAL,
"Hide",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
pDialog.dismiss();
}
});
pDialog.show();
我想为progrss对话框创建两个按钮,如何为进度对话框创建两个按钮?
答案 0 :(得分:0)
我们可以使用under code:
为ProgressDialog创建两个按钮 ProgressDialog myDialog = new ProgressDialog(this);
myDialog.setMessage("Loading...");
myDialog.setCancelable(false);
myDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
myDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// your code
}
});
myDialog.show();