如何在 alertDialog 中包含自定义标题栏?我知道 android sdk 提供 setCustomTitle 方法,但它不起作用
编辑:
AlertDialog alert = new AlertDialog.Builder(this).setTitle("Test").setMessage("hello").show();
View view=alert.getLayoutInflater().inflate(R.layout.titlebar, null);
alert.setCustomTitle(view);
但上面的代码不起作用
注意: 我不是在寻找自定义对话框,而只想自定义其标题布局。如下所示
最佳答案
您不应该在第一行使用 .show 方法,使用以下代码即可:
AlertDialog.Builder alert = new AlertDialog.Builder(this);
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.titlebar, null);
alert.setCustomTitle(view);
alert.setMessage("helo");
alert.show();
关于android - 如何在 android 的 AlertDialog 中包含自定义标题 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9430233/