如何将包括自定义标题视图与AlertDialog Android中? [英] how to include custom title view with in AlertDialog in android?
本文介绍了如何将包括自定义标题视图与AlertDialog Android中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么能包括在alertDialog自定义标题栏?我知道Android SDK中提供setCustomTitle方法,但它does'not工作
how can i include custom titlebar in alertDialog?I know android sdk provide setCustomTitle method but it does'not work
编辑:
AlertDialog alert = new AlertDialog.Builder(this).setTitle("Test").setMessage("hello").show();
View view=alert.getLayoutInflater().inflate(R.layout.titlebar, null);
alert.setCustomTitle(view);
但高于code不工作
but above code is not working
注意: 我不是在寻找自定义对话框,但只是想使下面
NOTE : I am not looking for custom dialog box but only want to makes its title layout custom..Like below
推荐答案
你不应该在第一行使用.show方法,使用下面的code它的工作原理:
you should not use the .show method with the first line, use the following code it works:
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();
这篇关于如何将包括自定义标题视图与AlertDialog Android中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文