Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Last active September 15, 2023 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/c0964e3df52ebe03ae7ed3f27fc3d431 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/c0964e3df52ebe03ae7ed3f27fc3d431 to your computer and use it in GitHub Desktop.
Android Quiz App Kotlin 4-4
private fun showNextQuiz() {
// クイズを1問取り出す
val quiz = quizData[0]
// 問題をセット
binding.questionLabel.text = quiz[0]
// 正解をセット
rightAnswer = quiz[1]
// 都道府県名を削除
quiz.removeAt(0)
// 正解と選択肢3つをシャッフル
quiz.shuffle()
// 正解と選択肢をセット
binding.answerBtn1.text = quiz[0]
binding.answerBtn2.text = quiz[1]
binding.answerBtn3.text = quiz[2]
binding.answerBtn4.text = quiz[3]
// 出題したクイズを削除する
quizData.removeAt(0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment