Android Studio 如何在Android java中设置提醒对话框?[已关闭]

agxfikkp  于 2022-12-23  发布在  Android
关注(0)|答案(1)|浏览(128)
    • 已关闭**。此问题需要超过focused。当前不接受答案。
    • 想要改进此问题吗?**更新此问题,使其仅关注editing this post的一个问题。

6小时前关门了。
Improve this question
如何在android java中设置提醒对话框?
如何在android java中设置提醒对话框?

jgwigjjp

jgwigjjp1#

正常的警报对话框如下所示

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Title of the alert dialog");
builder.setMessage("Message to be displayed in the alert dialog");
builder.setPositiveButton("Positive Button", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        // Code to be executed when the positive button is clicked
    }
});
builder.setNegativeButton("Negative Button", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        // Code to be executed when the negative button is clicked
    }
});

AlertDialog alertDialog = builder.create();
alertDialog.show();

您可以对此进行更多自定义。请查看Android documentation中的AlertDialog类

相关问题