我想在问答活动中随机出现问题和答案。
以下是QuizActivity.java的片段
private void updateQuestion(){
mQuestionView.setText(mQuestionLibrary.getQuestion(mQuestionNumber));
mButtonChoice1.setText(mQuestionLibrary.getChoice1(mQuestionNumber));
mButtonChoice2.setText(mQuestionLibrary.getChoice2(mQuestionNumber));
mButtonChoice3.setText(mQuestionLibrary.getChoice3(mQuestionNumber));
mButtonChoice4.setText(mQuestionLibrary.getChoice4(mQuestionNumber));
mAnswer = mQuestionLibrary.getCorrectAnswer(mQuestionNumber);
mQuestionNumber++;
}
private void updateScore(int point) {
mScoreView.setText("" + mScore);
}
以下是我在QuestionLibrary.java中的代码片段
public String getQuestion(int a) {
String question = mQuestions[a];
return question;
}
public String getChoice1(int a) {
String choice0 = mChoices[a][0];
return choice0;
}
public String getChoice2(int a) {
String choice1 = mChoices[a][1];
return choice1;
}
public String getChoice3(int a) {
String choice2 = mChoices[a][2];
return choice2;
}
public String getChoice4(int a) {
String choice3 = mChoices[a][3];
return choice3;
}
public String getCorrectAnswer(int a) {
String answer = mCorrectAnswers[a];
return answer;
}