我有一个对话框:标题、消息和 2 个按钮(中性和否定)我试图放置另一个中性或 Negavite 按钮,但它只显示每个按钮(中性和否定),所以有没有办法放置一个按钮还是我必须创建对话框的自定义布局?如果可以,怎么做?
代码:
AlertDialog.Builder dialogo = new AlertDialog.Builder(this);
dialogo.setMessage(msg);
dialogo.setTitle(titulo);
dialogo.setNeutralButton("OK", null);
dialogo.setNegativeButton("Delete", deletar);
dialogo.show();
最佳答案
您可以使用 setPositiveButton
添加第三个按钮,但除此之外,您还必须设置自定义 View 。要设置自定义 View ,您只需使用 AlertDialog.Builder
调用 setView(yourView)
。
关于android - 包含 2 个以上按钮的对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12518124/