gpt4 book ai didi

android - 如何在 android 中更改 .setpositivebutton 和 .setnegativebutton 默认主题颜色

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

在自定义警报对话框中,我包含了 .setPositive 和 .setNegative 按钮 我想将默认主题颜色更改为白色如何?请回答。我不想要 setOnClick 颜色答案。下面的代码 fragment

提前致谢问候mysmax

最佳答案

像这样做,但先做 alert.show() 然后改变颜色。

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Stackoverflow answer!")
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
//Use R.id.button1 and button2
((Button)alert.findViewById(android.R.id.button1)).setBackgroundResource("Set to what you want");

关于android - 如何在 android 中更改 .setpositivebutton 和 .setnegativebutton 默认主题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17954410/

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