Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between AlertDialog.builder.setView and Dialog.setContentView? [closed]

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?

like image 701
cameron Avatar asked May 29 '13 13:05

cameron


People also ask

What is the difference between dialog and AlertDialog?

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 .

What is the significance of AlertDialog builder?

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.

How do I close dialog on android?

You can use the methods cancel() or dismiss() . The method cancel() essentially the same as calling dismiss(), but it will also call your DialogInterface.

What is a dialog in Android Studio?

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.


1 Answers

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.

like image 140
codeMagic Avatar answered Sep 20 '22 10:09

codeMagic