Sunday, July 15, 2012

Get drawable Id based on string Android?


here is a code snippet on how to do it:


public static int getDrawable(Context context, String name)
{
Assert.assertNotNull(context);
Assert.assertNotNull(name);

return context.getResources().getIdentifier(name,"drawable", context.getPackageName());
}

No comments:

Post a Comment