views:

195

answers:

1

how can i get the resource id of an image if i know its name (in android)

+7  A: 

With something like this:

String mDrawableName = "myappicon";
int resID = getResources().getIdentifier(mDrawableName , "drawable", getPackageName());
Francesco
Thanks, that helped me find a solution to a simliar problem! I'll use `getResources().getIdentifier(name, "id", getPackageName());` to get the ID of an ImageButton (as you would with R.id.name).
Select0r