-
-
Save codingwithsara/c2a16d59c6285382fb2726f47fcde706 to your computer and use it in GitHub Desktop.
5-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void showNextQuiz() { | |
// 省略 | |
} | |
public void checkAnswer(View view) { | |
// どの回答ボタンが押されたか | |
Button answerBtn = findViewById(view.getId()); | |
String btnText = answerBtn.getText().toString(); | |
String alertTitle; | |
if (btnText.equals(rightAnswer)) { | |
alertTitle = "正解!"; | |
rightAnswerCount++; | |
} else { | |
alertTitle = "不正解..."; | |
} | |
// ダイアログを作成 | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle(alertTitle); | |
builder.setMessage("答え : " + rightAnswer); | |
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
if (quizCount == QUIZ_COUNT) { | |
// 結果画面へ移動 | |
} else { | |
quizCount++; | |
showNextQuiz(); | |
} | |
} | |
}); | |
builder.setCancelable(false); | |
builder.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment