Here are the docs:
AlertDialog.builder.setView : Set a custom view to be the contents of the Dialog.
Dialog.setContentView : Set the screen content to an explicit view.
But i am still a little confused, could anybody explain them in more details?
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
Android AlertDialog can be used to display the dialog message with OK and Cancel buttons. It can be used to interrupt and ask the user about his/her choice to continue or discontinue.
You can use the methods cancel() or dismiss() . The method cancel() essentially the same as calling dismiss(), but it will also call your DialogInterface.
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Dialog Design.
setView
does just that...sets one View
. So it could be a ListView
, TextView
, etc...
setContentView
is just like when you set it for an Activity
. It sets a complete layout
. Depending on which setContentView
you use it may be a parent layout
or a layout inflated from xml
setContentView(View view)
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.
or
setContentView(int layoutResID)
Set the screen content from a layout resource. The resource will be inflated, adding all top-level views to the screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With