gpt4 book ai didi

android - 一键关闭所有对话框

转载 作者:行者123 更新时间:2023-11-30 02:34:27 34 4
gpt4 key购买 nike

我想在单击此按钮时隐藏所有对话框:

new AlertDialog.Builder(FullscreenActivity.this)
.setTitle("Error!")
.setMessage(".......")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//hide all dialogs
}
}).setIcon(R.drawable.icon_error).show();

我该怎么做?我想用这个关闭所有以前打开的对话框。

最佳答案

May this help you.Create common method for calling dialog :

// Declare this as global variables
public static AlertDialog.Builder builder;
public AlertDialog dialog;
public Vector<AlertDialog> dialogs = new Vector<AlertDialog>();

public void alertDialog(String message) {
builder = new AlertDialog.Builder(this);
builder.setMessage(message).setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialogs.remove(dialog);
dialog.cancel();
}
});
dialog=builder.create();
dialogs.add(dialog);
dialog.show();

}

关于android - 一键关闭所有对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26800661/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com