remove Self From Parent View - Android User Interface

Android examples for User Interface:View Parent

Description

remove Self From Parent View

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

public class Main {
    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  . ja  va  2 s  .  com
            }
        }
    }
}

Related Tutorials