create View from layout id - Android User Interface

Android examples for User Interface:Layout

Description

create View from layout id

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;

public class Main {
    public static View createView(Context context, int layoutId) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);

        return inflater.inflate(layoutId, null, false);
    }/*from w  w  w  . j a va2 s  .  com*/
}

Related Tutorials