public class PopupWindowCompat
extends android.widget.PopupWindow
ViewTreeObserver by
PopupWindow.
PopupWindow registers an ViewTreeObserver.OnScrollChangedListener with
ViewTreeObserver, but does not keep a reference to the observer
instance that it has registers on. This is problematic when the anchor view
used by PopupWindow to access the observer is detached from the
window, as it will revert from the shared ViewTreeObserver owned
by the ViewRoot to a floating one, meaning
PopupWindow cannot unregister it's listener anymore and has
leaked it into the global observer.
This class works around this issue by
PopupWindow.mOnScrollChangedListener with a no-op
listener so that any registration or unregistration performed by
PopupWindow itself has no effect and causes no leaks.
ViewTreeObserver and keeping a reference to it to facilitate
correct unregistration. The reason for not registering on a floating observer
(before a view is attached) is that there is no safe way to get a reference
to the shared observer that the floating one will be merged into. This would
again cause the listener to leak.
| Constructor and Description |
|---|
PopupWindowCompat() |
PopupWindowCompat(android.content.Context context) |
PopupWindowCompat(android.content.Context context,
android.util.AttributeSet attrs) |
PopupWindowCompat(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle) |
PopupWindowCompat(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes) |
PopupWindowCompat(int width,
int height) |
PopupWindowCompat(android.view.View contentView) |
PopupWindowCompat(android.view.View contentView,
int width,
int height) |
PopupWindowCompat(android.view.View contentView,
int width,
int height,
boolean focusable) |
| Modifier and Type | Method and Description |
|---|---|
void |
dismiss() |
void |
showAsDropDown(android.view.View anchor,
int xoff,
int yoff) |
void |
showAtLocation(android.view.View parent,
int gravity,
int x,
int y) |
void |
update(android.view.View anchor,
int width,
int height) |
void |
update(android.view.View anchor,
int xoff,
int yoff,
int width,
int height) |
getAnimationStyle, getBackground, getContentView, getHeight, getInputMethodMode, getMaxAvailableHeight, getMaxAvailableHeight, getSoftInputMode, getWidth, isAboveAnchor, isClippingEnabled, isFocusable, isOutsideTouchable, isShowing, isSplitTouchEnabled, isTouchable, setAnimationStyle, setBackgroundDrawable, setClippingEnabled, setContentView, setFocusable, setHeight, setIgnoreCheekPress, setInputMethodMode, setOnDismissListener, setOutsideTouchable, setSoftInputMode, setSplitTouchEnabled, setTouchable, setTouchInterceptor, setWidth, setWindowLayoutMode, showAsDropDown, update, update, update, updatepublic PopupWindowCompat()
public PopupWindowCompat(android.content.Context context)
public PopupWindowCompat(android.content.Context context,
android.util.AttributeSet attrs)
public PopupWindowCompat(android.content.Context context,
android.util.AttributeSet attrs,
int defStyle)
public PopupWindowCompat(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
public PopupWindowCompat(int width,
int height)
public PopupWindowCompat(android.view.View contentView)
public PopupWindowCompat(android.view.View contentView,
int width,
int height,
boolean focusable)
public PopupWindowCompat(android.view.View contentView,
int width,
int height)
public void showAsDropDown(android.view.View anchor,
int xoff,
int yoff)
showAsDropDown in class android.widget.PopupWindowpublic void update(android.view.View anchor,
int xoff,
int yoff,
int width,
int height)
update in class android.widget.PopupWindowpublic void update(android.view.View anchor,
int width,
int height)
update in class android.widget.PopupWindowpublic void showAtLocation(android.view.View parent,
int gravity,
int x,
int y)
showAtLocation in class android.widget.PopupWindowpublic void dismiss()
dismiss in class android.widget.PopupWindowCopyright © 2014 se.solovyev. All Rights Reserved.