inflate View Layout - Android User Interface

Android examples for User Interface:Layout

Description

inflate View Layout

Demo Code


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

public class Main {
    public static View inflateView(Context context, int layoutId) {
        return inflateView(context, layoutId, null);
    }//from   w w w.jav a 2s  .c  om

    public static View inflateView(Context context, int layoutId,
            ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        return inflater.inflate(layoutId, parent, false);
    }

    public static View inflateView(int layoutId, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        return inflater.inflate(layoutId, parent, false);
    }
}

Related Tutorials