Java tutorial
//package com.java2s; import android.content.Context; public class Main { public static int getDrawableId(Context context, String filename) { return context.getResources().getIdentifier(filename, "drawable", context.getPackageName()); } }