gpt4 book ai didi

android - 如何添加带有 'OK' 按钮的消息框?

转载 作者:IT老高 更新时间:2023-10-28 13:11:44 25 4
gpt4 key购买 nike

我想显示一个带有确定按钮的消息框。我使用了以下代码,但它会导致带有参数的编译错误:

AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);
dlgAlert.setMessage("This is an alert with no consequence");
dlgAlert.setTitle("App Title");
dlgAlert.setPositiveButton("OK", null);
dlgAlert.setCancelable(true);
dlgAlert.create().show();

我应该如何在 Android 中显示消息框?

最佳答案

我认为您没有为确定正按钮添加点击监听器可能存在问题。

dlgAlert.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//dismiss the dialog
}
});

关于android - 如何添加带有 'OK' 按钮的消息框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6264694/

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