-
-
Save codeforfun-jp/beb7f5da025e5a646f1d69a22d08cadb to your computer and use it in GitHub Desktop.
Java Quiz - 2023 - 5
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() { | |
/* 省略 */ | |
} | |
@Override | |
public void onClick(View view) { | |
// どの解答ボタンが押されたか | |
Button answerBtn = findViewById(view.getId()); | |
String btnText = answerBtn.getText().toString(); | |
String alertTitle; | |
if (btnText.equals(rightAnswer)) { | |
alertTitle = "正解!"; | |
rightAnswerCount++; | |
} else { | |
alertTitle = "不正解..."; | |
} | |
// ダイアログを作成 | |
new MaterialAlertDialogBuilder(this) | |
.setTitle(alertTitle) | |
.setMessage("答え : " + rightAnswer) | |
.setPositiveButton("OK", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
if (quizCount == QUIZ_COUNT) { | |
// 結果画面へ移動 | |
} else { | |
quizCount++; | |
showNextQuiz(); | |
} | |
} | |
}) | |
.setCancelable(false) | |
.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment