Dialog.setContentView(View)&之间的区别是什么? AlertDialog.setView(查看) [英] What is difference between Dialog.setContentView( View ) & AlertDialog.setView( View )

查看:404
本文介绍了Dialog.setContentView(View)&之间的区别是什么? AlertDialog.setView(查看)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个自定义对话框,以从用户那里获取输入.我注意到,当我使用AlertDialog时,可以使用setView()方法将诸如EditText之类的小部件添加到AlertDialog中.我正在研究自定义AlertDialog,并注意到Dialog具有方法setContentView().在AlertDialog的子类中,我可以使用setContentView()setView().

I'm working on creating a custom dialog to get input from the user. I've noticed that when I use an AlertDialog I can add widgets such as an EditText to the AlertDialog using setView() method. I'm looking into customizing AlertDialog and noticed that Dialog has a method setContentView(). In the subclass of AlertDialog I could use either setContentView() or setView().

我注意到的一个不同之处是,当我在AlertDialog上使用setView()时,我可以看到正&负按钮.在AlertDialog的子类中,使用setContentView()时,我没有得到正数&.负按钮.

One difference I've noticed is when I use setView() on an AlertDialog, I can see Positive & Negative buttons. In my subclass of AlertDialog, using setContentView() I don't get the Positive & Negative buttons.

有人可以解释其他差异吗?

Can anyone explain other differences?

谢谢.

推荐答案

如果我没有正确理解它,则setContentView使用您的自定义布局将整个对话框"窗口放大.标题,图标,按钮...什么都没有.另一方面,setView设置按钮和标题之间的视图布局.

If I undesrstood it correctly, setContentView inflates the entire Dialog window with your custom layout. Title, icon, buttons... nothing remains. setView on the other hand sets the layout of the view between the buttons and the title.

这篇关于Dialog.setContentView(View)&之间的区别是什么? AlertDialog.setView(查看)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆