I didn't architect this, but here's the situation : there is a PopupWindow with a button in it. The button handler is in a different activity from the Activity that created the PopupWindow. I want to know if there's a way to use the View param to the button handler to access the PopupWindow to have it despedir() itself when I tap the button.
So far I've been able to use a series of getParent ()'s to iterate up to the containing PopupWindow. But when I do it says it's a "PopupWindow$PopupViewContainer" (PopupWindow itself is not derived from View; it's derived from Object)
Is there any way I can use this to access the actual PopupWindow so I can call its despedir() ¿método?
Gracias de antemano!
preguntado el 01 de febrero de 12 a las 03:02
I didn't architect this...
If you're working on it, then I suggest you (slightly) change the architecture to make it right.
Here is what I suggest: (I suppose the code for the handler is in another activity because these two activities can have the popup window?)
Extract a base superclass for all the activities that can have the popup window, (make it
extends Activity, and all your concrete activities will extend that class), and put the handler code in this one.
Keep a reference to the parent
PopupWindowin that base activity, so you can always access it from the handler, or from anything else that might need it (keep that reference private to preserve encapsulation).
for Popup window there : duplicate Ventana emergente just see the solution for this.
and if you are talking about the dismiss();
public void dismiss ()
Dispose of the popup window. This method can be invoked only after
showAsDropDown(android.view.View) ha sido ejecutado.