Example usage for android.view ViewGroup removeViewAt

List of usage examples for android.view ViewGroup removeViewAt

Introduction

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

Prototype

public void removeViewAt(int index) 

Source Link

Document

Removes the view at the specified position in the group.

Usage

From source file:Main.java

private static void addTranslucentView(Activity activity, int statusBarAlpha) {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    if (contentView.getChildCount() > 1) {
        contentView.removeViewAt(1);
    }// w  w  w  . j ava2s  .  co m
    contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}

From source file:Main.java

public static void swapViewGroupChildren(ViewGroup viewGroup, View firstView, View secondView) {
    int firstIndex = viewGroup.indexOfChild(firstView);
    int secondIndex = viewGroup.indexOfChild(secondView);
    if (firstIndex < secondIndex) {
        viewGroup.removeViewAt(secondIndex);
        viewGroup.removeViewAt(firstIndex);
        viewGroup.addView(secondView, firstIndex);
        viewGroup.addView(firstView, secondIndex);
    } else {/*from  w  w w.  jav  a 2s.c om*/
        viewGroup.removeViewAt(firstIndex);
        viewGroup.removeViewAt(secondIndex);
        viewGroup.addView(firstView, secondIndex);
        viewGroup.addView(secondView, firstIndex);
    }
}

From source file:edu.com.mvplibrary.ui.widget.StatusBarUtil.java

/**
 * ???//from   w  w w  .j  a v  a2s .  c  o  m
 *
 * @param activity       ? activity
 * @param statusBarAlpha ?
 */
private static void addTranslucentView(Activity activity, int statusBarAlpha) {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    // ??,??
    if (contentView.getChildCount() > 1) {
        contentView.removeViewAt(1);
    }
    contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}

From source file:com.gosuncn.core.util.view.StatusBarUtils.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content))
                .getChildAt(0);//from w w  w. j a  va2 s . c o m
        rootView.setPadding(0, 0, 0, 0);
    }
}

From source file:com.kk.binding.adapter.SimpleBindPagerAdapter.java

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    container.removeViewAt(position);
}

From source file:com.dv.View.PullToRefresh.ListFragment.DvBaseListFragment.java

@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = super.onCreateView(inflater, container, savedInstanceState);

    ListView lv = (ListView) layout.findViewById(android.R.id.list);
    ViewGroup parent = (ViewGroup) lv.getParent();

    // Remove ListView and add DvListView in its place
    int lvIndex = parent.indexOfChild(lv);
    parent.removeViewAt(lvIndex);
    mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState);
    parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams());

    return layout;
}

From source file:com.benefit.buy.library.pulltorefresh.library.listfragment.PullToRefreshBaseListFragment.java

@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = super.onCreateView(inflater, container, savedInstanceState);
    ListView lv = (ListView) layout.findViewById(android.R.id.list);
    ViewGroup parent = (ViewGroup) lv.getParent();
    // Remove ListView and add PullToRefreshListView in its place
    int lvIndex = parent.indexOfChild(lv);
    parent.removeViewAt(lvIndex);
    mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState);
    parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams());
    return layout;
}

From source file:club.xlxk.libs.pulltorefresh.library.extras.PullToRefreshBaseListFragment.java

@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = super.onCreateView(inflater, container, savedInstanceState);

    ListView lv = (ListView) layout.findViewById(android.R.id.list);
    ViewGroup parent = (ViewGroup) lv.getParent();

    // Remove ListView and add PullToRefreshListView in its place
    int lvIndex = parent.indexOfChild(lv);
    parent.removeViewAt(lvIndex);
    mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState);
    parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams());

    return layout;
}

From source file:com.actionbarsherlock.internal.view.menu.BaseMenuPresenter.java

/**
 * Filter the child view at index and remove it if appropriate.
 * @param parent Parent to filter from/*from ww w .java 2s .c o m*/
 * @param childIndex Index to filter
 * @return true if the child view at index was removed
 */
protected boolean filterLeftoverView(ViewGroup parent, int childIndex) {
    parent.removeViewAt(childIndex);
    return true;
}

From source file:com.minglang.pulltorefreshlibrary.listfragment.PullToRefreshBaseListFragment.java

@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = super.onCreateView(inflater, container, savedInstanceState);

    ListView lv = null;/*from  ww  w .  j  a  v  a2s .  c  o m*/
    if (layout != null) {
        lv = (ListView) layout.findViewById(android.R.id.list);
    }
    ViewGroup parent = null;
    if (lv != null) {
        parent = (ViewGroup) lv.getParent();
    }

    // Remove ListView and add PullToRefreshListView in its place
    int lvIndex = 0;
    if (parent != null) {
        lvIndex = parent.indexOfChild(lv);
        parent.removeViewAt(lvIndex);
        mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState);
        parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams());
    }

    return layout;
}