Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; public class Main { /** * @param context * @param name * @return */ public static int getImageResourceId(Context context, String name) { try { return context.getResources().getIdentifier(name, "drawable", context.getPackageName()); } catch (Exception e) { e.printStackTrace(); return -1; } } }