gpt4 book ai didi

java - 如果用户在警报对话框中按"is"按钮,如何在列表中添加项目,而如果按“否”则不添加该项目

转载 作者:行者123 更新时间:2023-12-01 15:47:50 24 4
gpt4 key购买 nike

我正在制作一个应用程序,如果用户选择子菜单项我弹出一个警报对话框,要求他确认他是否希望将该项目保存在他的列表中,如果他愿意,则保存它按"is",如果按“否”则不添加。

最佳答案

您可以使用它来显示警报:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure to do this?").setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
doSomeThing();
dialog.cancel();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();

关于java - 如果用户在警报对话框中按"is"按钮,如何在列表中添加项目,而如果按“否”则不添加该项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6778844/

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