Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android:PopupWindow.showAtLocation()

Tags:

android

Can anyone tell me the detail explanation of the param "parent" in the function PopupWindow.showAtLocation(View **parent**,int w,int h); Thanks in advance!

like image 776
Rocky Avatar asked Oct 28 '11 08:10

Rocky


People also ask

How do I pass custom layout to popupMenu?

OnClickListener() { @Override public void onClick(View view) { PopupMenu popupMenu = new PopupMenu(Sample1. this, view); popupMenu. setOnMenuItemClickListener(Sample1. this); popupMenu.

What is pop-up window Android?

android.widget.PopupWindow. 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.


1 Answers

The Android window manager makes sure that the popup window is shown above the activity that showed it. In order for the window manager to do this, it needs to know the window of the activity in question. Since a View is inside a window, it knows what window the activity is in if it knows of a View inside the activity window.

With the parent parameter, you say "I want the popup window above the activity in the window that the View parent is in".

like image 184
Martin Nordholts Avatar answered Oct 06 '22 21:10

Martin Nordholts