get Layout Id By Name from resource - Android App

Android examples for App:Resource

Description

get Layout Id By Name from resource

Demo Code


//package com.java2s;

import android.content.Context;
import android.util.Log;

public class Main {

    public static int getLayoutIdByName(Context context, String name,
            String packageName) {
        Log.d("cqm", "package name is " + packageName);
        return context.getResources().getIdentifier(name, "layout",
                packageName);//ww  w .ja  v  a2 s . c  o  m
    }
}

Related Tutorials