What is the difference between PopUpWindow and Dialog?

Dennis picture Dennis · Sep 10, 2012 · Viewed 17.2k times · Source

Basically the question is stated in the title. Any preferences in using one or another? Maybe some specific tasks where one is superior/ more efficient/ better than the other?

Answer

Rohan Pawar picture Rohan Pawar · Feb 1, 2017

Dialog

"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."

AlertDialog has many variants and as far as I can assume your problem, You can have a cross button too in the top-right corner of the dialog (You can set the icons anywhere, as you can provide a custom layout to an AlertDialog).

-Capable of adding any view

-Easy to edit

-Can be adapted to tablets or cellphones in landscape or portrait just by modifying the layout

-Can dedicate a whole new class just to modify it your way

PopupWindows

"This class represents a popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity."

PopupWindow is another tool to customize your custom pop up anywhere in the screen. If you're showing this popup always in the middle of the screen, then I would like to suggest not to use this. The AlertDialog should work fine.

-Simpler

-Easier to code

-It's more standard so it'll be harder for the user to be confused with it