Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Android PopupWindow vs Dialog

I'm unclear about when to use PopupWindow vs Dialog. Any insight would be much appreciated. Thanks.

like image 344
Julian A. Avatar asked Jan 17 '11 05:01

Julian A.


People also ask

What is difference between popup and dialog?

“Popup Windows” — Pop up a new window that displays a Zen page or any other content. “Dialogs” — Pop up a dialog that prompts the user and accepts user input.

What is the use of dialog in android?

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.

How do I know if my android is dialog?

Dialog has an isShowing() method that should return if the dialog is currently visible. So you can use that to see if a dialog is showing and hide it with dismissDialog(). You just have to keep a reference to the Dialogs you create in onCreateDialog().


2 Answers

They both use the addView() method along with various windowManager methods. The two are similar in that regard.

Dialogs seem to come with more built-in features for interaction, such as handlers and buttons already included in the base class, while PopupWindows come with more built-in methods for positioning them about the screen.

I think that each of them can do exactly the same as the other, but choosing between the two will be a matter of convenience to the programmer with regards to how you want to use the Object. I'm not a phD in computer science, but I do not think there is a significant difference in processing time between the two based on what I saw in their respective class definitions.

My advice: If you want to have greater control over where your View appears on the display, use a PopupWindow. If you want to add more control and feedback between your View then use a Dialog. If you, like me, want master control over everything, I would suggest a PopupWindow since it has fewer user-evident default methods to override.

like image 101
Glen Pierce Avatar answered Sep 29 '22 15:09

Glen Pierce


I think, that you should use Dialog for simple user interaction (YES,NO). I usually use Dialog for simple user interaction and WindowPopup for a little bit more complex view. One example of WindowPopup is AutoCompleteTextView.

Hope it helps.

like image 40
SlowTree Avatar answered Sep 29 '22 15:09

SlowTree