He empezado un curso para Android Studio
con Java. Durante el desarrollo de una "app ejercicio" en clase nos hicieron escribir esto:
RadioButton btn_resp1 = findViewById(R.id.btn_resp0);
btn_resp1.setText(pregunta.getResp()[0]);
RadioButton btn_resp2 = findViewById(R.id.btn_resp1);
btn_resp2.setText(pregunta.getResp()[1]);
RadioButton btn_resp3 = findViewById(R.id.btn_resp2);
btn_resp3.setText(pregunta.getResp()[2]);
RadioButton btn_resp4 = findViewById(R.id.btn_resp3);
btn_resp4.setText(pregunta.getResp()[3]);
¿Se puede optimizar (reducir la cantidad de código) este código con un bucle for para no tener que escribir 4 veces prácticamente lo mismo?