Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; public class Main { /** * Retrieves the resource ID from a string (for example, a drawable from the * image name). * * @param context Application or Activity context * @param type Resource type * @param resourceName Resource's name * * @return Resource ID of the named resource */ public static int resourceIdFromString(final Context context, final String type, final String resourceName) { return context.getResources().getIdentifier(resourceName, type, context.getPackageName()); } }