Example usage for android.view ViewGroup removeView

List of usage examples for android.view ViewGroup removeView

Introduction

In this page you can find the example usage for android.view ViewGroup removeView.

Prototype

@Override
public void removeView(View view) 

Source Link

Document

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

Usage

From source file:Main.java

public static void removeParent(View view) {

    ViewParent parent = view.getParent();

    if (parent instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) parent;
        group.removeView(view);
    }//from  w  w w.j av a2  s .co m
}

From source file:Main.java

public static void removeSelfFromParent(View child) {
    if (child != null) {
        ViewParent parent = child.getParent();
        if (parent != null && parent instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) parent;
            group.removeView(child);
        }/*from  w w  w.  j a  v  a  2  s  .  co  m*/
    }
}

From source file:Main.java

public static void removeViewFromGroup(View previousView, ViewGroup root) {
    if (previousView != null) {
        root.removeView(previousView);
    }//from   w w  w.j  a va2s.c  o m
}

From source file:Main.java

public static void removeSelfFromParent(View child) {
    if (child != null) {
        ViewParent parent = child.getParent();
        if (parent != null && parent instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) parent;
            viewGroup.removeView(child);
        }/*from  w  ww  .j av a 2s  . c  o  m*/
    }

}

From source file:Main.java

public static void removeSelfFromParent(View child) {

    if (child != null) {

        ViewParent parent = child.getParent();

        if (parent instanceof ViewGroup) {

            ViewGroup group = (ViewGroup) parent;

            group.removeView(child);
        }/*from  w  w  w.j  av a2  s.  c om*/
    }
}

From source file:Main.java

public static void removeSelfFromParent(View view) {
    if (view != null) {
        ViewParent parent = view.getParent();
        if (parent != null && parent instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) parent;
            group.removeView(view);
        }/*from w w w .  j a  v a2  s .c o  m*/
    }
}

From source file:Main.java

public static void removeFromSuperView(View view) {
    ViewGroup parent = (ViewGroup) view.getParent();
    if (parent != null)
        parent.removeView(view);
}

From source file:Main.java

public static void removeSelf(View child) {
    if (null == child)
        return;/*  w w w .  j  a  va2 s  . c o  m*/
    if (child.getParent() instanceof ViewGroup) {
        ViewGroup parent = (ViewGroup) child.getParent();
        if (null != parent)
            parent.removeView(child);
    }
}

From source file:Main.java

public static void removeView(Activity act, View v) {
    ViewGroup root = (ViewGroup) act.findViewById(android.R.id.content);
    root = (ViewGroup) root.getChildAt(0);
    root.removeView(v);
}

From source file:Main.java

private static void unwrapView(ViewGroup wrapper) {
    final int childCount = wrapper.getChildCount();
    View[] childViews = new View[childCount];

    ViewGroup parent = (ViewGroup) wrapper.getParent();

    if (parent != null) {
        parent.removeView(wrapper);
    }/* w  ww.j  a v a  2 s  .  co  m*/

    for (int i = 0; i < childCount; i++) {
        childViews[i] = wrapper.getChildAt(i);
    }

    // If there was just one wrapper reuse the wrapper layout
    // params to ensure correct type for parent
    if (childCount == 1) {
        ViewGroup.LayoutParams wrapperParams = wrapper.getLayoutParams();
        if (wrapperParams != null) {
            childViews[0].setLayoutParams(wrapperParams);
        }
    }

    for (int i = 0; i < childCount; i++) {
        final View childView = childViews[i];

        wrapper.removeView(childView);
        if (parent != null) {
            parent.addView(childView);
        }
    }
}