I have this simple app that works like a quiz. The main problem is that sometimes, some questions don't show the right option, as there is only 4 buttons for options and more than 10 items on the list. Here is the code:
private void createOptions() {
List<String> options;
if ("Intervalo Musical".equals(receivedText)) {
options = new ArrayList<>(Globals.intervalos);
} else if ("Qualidade do Acorde".equals(receivedText)) {
options = Arrays.asList("Maior", "Menor", "Diminuto", "Aumentado");
} else if ("Escala Musical".equals(receivedText)) {
options = new ArrayList<>(Globals.escalas);
}
/*else {
options = Arrays.asList("Opção 1", "Opção 2", "Opção 3", "Opção 4");
}
*/
if (!options.contains(QUESTION_CORRECT)) {
options.add(QUESTION_CORRECT);
}
Collections.shuffle(options);
quizOptionA.setText(options.get(0));
quizOptionB.setText(options.get(1));
quizOptionC.setText(options.get(2));
quizOptionD.setText(options.get(3));
}
and here is where QUESTION_CORRECT is setted:
private void createSound() {
String midiFileName = intent.getStringExtra("midiFileName");
if (midiFileName != null) {
SOUND_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) + "/EAR/" + midiFileName + ".mid";
File file = new File(SOUND_PATH);
if (file.exists()) {
Log.i("SoundCheck", "Arquivo .mid encontrado: " + SOUND_PATH);
QUESTION_CORRECT = midiFileName;
} else {
Log.e("SoundCheck", "Arquivo .mid não encontrado: " + SOUND_PATH);
}
} else {
Log.e("SoundCheck", "midiFileName é nulo");
}
}
what am I missing?
trying to put the right answer to be shown on every question of the quiz