Code example for ViewTreeObserver

Methods: addOnGlobalLayoutListener

0
    public void onViewAttachedToWindow(View v) {
        ((View_HasStateListenerSupport) v).removeOnAttachStateChangeListener(this);
 
        // The anchor wasn't attached in tryShow(), attach to the ViewRoot VTO now. 
        if (mPopup != null && mTreeObserver == null) {
            (mTreeObserver = v.getViewTreeObserver()).addOnGlobalLayoutListener(this);
        } 
    } 
 
    @Override 
    public void onViewDetachedFromWindow(View v) {
    } 
 
    @Override 
    public void initForMenu(Context context, MenuBuilder menu) {
        // Don't need to do anything; we added as a presenter in the constructor. 
    } 
 
    @Override 
    public MenuView getMenuView(ViewGroup root) {
        throw new UnsupportedOperationException("MenuPopupHelpers manage their own views");