add View To Parent - Android User Interface

Android examples for User Interface:View Parent

Description

add View To Parent

Demo Code


//package com.java2s;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class Main {
    public static void addViewToParent(LayoutInflater inflater,
            ViewGroup parent, int viewToAdd) {
        addViewToParent(inflater, parent, viewToAdd, 0);
    }/*from  w  w w.  j  a  va2 s  . co  m*/

    public static void addViewToParent(LayoutInflater inflater,
            ViewGroup parent, int viewToAdd, int index) {
        parent.addView(inflater.inflate(viewToAdd, parent, false), index);
    }

    public static void addViewToParent(ViewGroup parent, View viewToAdd) {
        addViewToParent(parent, viewToAdd, 0);
    }

    public static void addViewToParent(ViewGroup parent, View viewToAdd,
            int index) {
        parent.addView(viewToAdd, index);
    }
}

Related Tutorials