Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    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);
        }

        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);
            }
        }
    }
}