Code example for ViewTreeObserver

Methods: isAlive, removeGlobalOnLayoutListener

0
 
    public void onDismiss() { 
        mPopup = null;
        mMenu.close();
        if (mTreeObserver != null) {
            if (mTreeObserver.isAlive()) mTreeObserver.removeGlobalOnLayoutListener(this);
            mTreeObserver = null;
        } else if (mAnchorView instanceof View_HasStateListenerSupport) {
            ((View_HasStateListenerSupport) mAnchorView).removeOnAttachStateChangeListener(this);
        } 
    } 
 
    public boolean isShowing() { 
        return mPopup != null && mPopup.isShowing();
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        MenuAdapter adapter = mAdapter;
        adapter.mAdapterMenu.performItemAction(adapter.getItem(position), 0);
    }