Code example for ViewGroup

Methods: removeView, getParent, setBackgroundColor, setOnClickListener

0
        } 
        if (mDecorContent != null) {
            /* 
             * Add the window/content (whatever it is at the time) back to its original parent. 
             */ 
            removeView(mDecorContent);
            mDecorContentParent.addView(mDecorContent);
 
            /* 
             * Reset the window/content's OnClickListener/background color to default values as well 
             */ 
            mDecorContent.setOnClickListener(null);
            mDecorContent.setBackgroundColor(Color.TRANSPARENT);
        } 
        if (mAdded) {
            mDecorContentParent.removeView(this);
        } 
        if (mSlideTarget == SLIDE_TARGET_CONTENT) {
            mDecorContent = mContentTarget;
            mDecorContentParent = mContentTargetParent;
        } else if (mSlideTarget == SLIDE_TARGET_WINDOW) {
            mDecorContent = mWindowTarget;
            mDecorContentParent = mWindowTargetParent;
        } else { 
            throw new IllegalArgumentException(
                    "Slide target must be one of SLIDE_TARGET_CONTENT or SLIDE_TARGET_WINDOW."); 
        } 
        ((ViewGroup) mDecorContent.getParent()).removeView(mDecorContent);
        addView(mDrawerContent, new ViewGroup.LayoutParams(mDrawerMaxWidth, MATCH_PARENT));
        addView(mDecorContent, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
        mDecorContentParent.addView(this);
        mAdded = true;
 
        /* Set background color of the content view (it defaults to transparent) */ 
        mDecorContent.setBackgroundColor(mDecorContentBackgroundColor);
 
        /* Reset shadow bounds */ 
        mShadowDrawable.setBounds(-mTouchTargetWidth / 6, 0, 0, dm.heightPixels);
 
        /* 
         * Set an empty onClickListener on the Decor content parent to prevent any touch events 
         * from escaping and passing through to the drawer even while it's closed. 
         */ 
        mDecorContent.setOnClickListener(new OnClickListener() {
            @Override 
            public void onClick(View view) {
            } 
        }); 
    }