What is the difference between AlertDialog.builder.setView and Dialog.setContentView?

Here are the docs:

AlertDialog.builder.setView : Set a custom view as the contents of a dialog box.

Dialog.setContentView : set the contents of the screen to an explicit view.

But I'm still a little confused, can someone explain them in more detail?

+6
source share
1 answer

setView does just that ... sets up one View . So it could be ListView , TextView , etc.

setContentView similar to when you set it for an Activity . He installs the full layout . Depending on which setContentView you are using, there may be a parent layout or a layout inflated by xml

setContentView(View view)

Set the screen contents to an explicit view. This view is placed directly in the screen display hierarchy. He himself can be a complicated look.

or

setContentView(int layoutResID)

Set the screen contents from the layout resource. The resource will be overstated by adding all the top-level views to the screen.

+9
source

Source: https://habr.com/ru/post/946089/


All Articles