作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有自己的自定义对话框,如下所示:
public class BerekenDialog extends Dialog{
public BerekenDialog(Context context) {
super(context);
setContentView(R.layout.bereken_dialog_layout);
this.setTitle("Bereken");
//dostuff.
}
}
我的对话是这样开始的:
BerekenDialog bd = new BerekenDialog (this);
bd.show();
有没有办法将警告对话框中的否定、肯定和中性按钮添加到我的自定义对话框中?
最佳答案
get data from some spinners, make a calculation with the data and display it
您可以在不创建自定义对话框的情况下执行此操作,只有在构建器中创建它时才会创建正负按钮。没有办法实现它,您可以在带有按钮的 xml 布局中创建自己的布局。
在不使用自定义的情况下创建警报对话框:
AlertDialog a = new AlertDialog.Builder(this)
.setTitle("Bereken")
.setView(getLayoutInflater().inflate( R.layout.bereken_dialog_layout,null))
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// ok button
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// cancel button
}
}).create();
TextView tv = (TextView)a.findViewById(r.id.your_id); //use the instance of textview from layout of dialog
tv.setText("update"); //set is before displaying
a.show();
关于android setNegativeButton 自定义对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25251050/
我有自己的自定义对话框,如下所示: public class BerekenDialog extends Dialog{ public BerekenDialog(Context contex
在自定义警报对话框中,我包含了 .setPositive 和 .setNegative 按钮 我想将默认主题颜色更改为白色如何?请回答。我不想要 setOnClick 颜色答案。下面的代码 fragm
必须在 onClick 中调用 dismiss() 吗?如果我没有调用 dismiss(),对话框仍然可以关闭。 @Override public Dialog onCreateDialog(Bund
我是一名优秀的程序员,十分优秀!