Android examples for User Interface:Layout Inflater
find Layout Id By Name
//package com.java2s; import android.content.Context; public class Main { private static final int DEFAULT_LAYOUT_ID = -1; public static int findLayoutIdByName(Context context, final String layoutName) { int resourceId = DEFAULT_LAYOUT_ID; try {//from w ww .j ava 2 s .c o m resourceId = context.getResources().getIdentifier(layoutName, "style", context.getPackageName()); } catch (final Exception e) { e.printStackTrace(); resourceId = DEFAULT_LAYOUT_ID; } return resourceId; } public static String getPackageName(Context context) { return context.getPackageName(); } }