for (int i = 1; i <= maxBotones; i++){ int boton = getResources().getIdentifier("boton" + i, "id", getPackageName()); boton.setEnabled(true); }