Code example for WindowManager

Methods: addView, removeView

0
            mParams.x = mX;
            mParams.y = mY;
            mParams.verticalMargin = mVerticalMargin;
            mParams.horizontalMargin = mHorizontalMargin;
            if (mView.getParent() != null) {
                mWM.removeView(mView);
            } 
            mWM.addView(mView, mParams);
        } 
    } 
 
    private synchronized void handleHide() { 
        if (mView != null) {
            // note: checking parent() just to make sure the view has 
            // been added...  i have seen cases where we get here when 
            // the view isn't yet added, so let's try not to crash. 
            if (mView.getParent() != null) {
                mWM.removeView(mView);
            } 
            mView = null;
        }