Java tutorial
//package com.java2s; import android.content.Context; import android.text.TextUtils; public class Main { public static int getResourceId(Context context, String resourcesName, String type) { if (null == context || TextUtils.isEmpty(resourcesName) || TextUtils.isEmpty(type)) { return -1; } return context.getResources().getIdentifier(resourcesName, type, context.getPackageName()); } }