When to use Android PopupWindow vs Dialog

Julian A. picture Julian A. · Jan 17, 2011 · Viewed 10.2k times · Source

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

Answer

Glen Pierce picture Glen Pierce · Apr 26, 2015

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.