Android examples for User Interface:ViewGroup
insert View to ViewGroup
// Copyright (c) 2013 The Chromium Authors. All rights reserved. //package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { private static int insertView(ViewGroup container, View newView, View existingView, boolean after) { // See if the view has already been added. int index = container.indexOfChild(newView); if (index >= 0) return index; // Find the location of the existing view. index = container.indexOfChild(existingView); if (index < 0) return -1; // Add the view. if (after) index++;//ww w. j av a 2 s .co m container.addView(newView, index); return index; } }