Code example for ViewTreeObserver

Methods: isAliveremoveGlobalOnLayoutListener

        public void onDismiss() { 
            if (mPopupWindow == null) return; 
            mPopupWindow = null; 
            ViewTreeObserver observer = mAnchorView.getViewTreeObserver(); 
            if (observer.isAlive()) { 
                // We used the deprecated function for backward compatibility 
                // The new "removeOnGlobalLayoutListener" is introduced in API level 16 
    private final OnItemClickListener mOnItemClickListener =
            new OnItemClickListener() { 
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
            if (mPopupWindow == null) return; 
            if (mOnPopupItemClickListener != null) { 
Experience pair programming with AI  Get Codota for Java