Here you can find the source of getDrawableByName(Context ctx, String name)
public static Bitmap getDrawableByName(Context ctx, String name)
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap getDrawableByName(Context ctx, String name) { BitmapFactory.Options options = new BitmapFactory.Options(); Bitmap bitmap = BitmapFactory.decodeResource( ctx.getResources(),// w ww .ja va 2 s. c om ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName()), options); return bitmap; } }