以下是文档:
AlertDialog.builder.setView:将自定义视图设置为Dialog的内容.
Dialog.setContentView:将屏幕内容设置为显式视图.
但我仍然有点困惑,任何人都可以更详细地解释它们吗?
解决方法
setView就是这样……设置一个View.所以它可能是ListView,TextView等……
setContentView就像为Activity设置它一样.它设置了完整的布局.根据您使用的setContentView,它可能是父布局或从xml膨胀的布局
setContentView(视图视图)
Set the screen content to an explicit view. This view is placed directly into the screen’s view hierarchy. It can itself be a complex view hierarhcy.
要么
setContentView(int layoutResID)
Set the screen content from a layout resource. The resource will be inflated,adding all top-level views to the screen.