Explaining how to access any resource by variable, not directly. Example with "drawables".
String icon="logo" + cnt; int resID = getResources().getIdentifier(icon, "drawable", getPackageName()); logo.setImageResource(resID);