public class QuizActivity extends AppCompatActivity {
private Button mTrueButton;
private Button mFalseButon;
private Button mNextBuuttonn;
private Button mPrevButton;
private TextView mQuestionTextView;
private Question [] mQuestionBank = new Question[]{
new Question(R.string.question_australia, true),
new Question(R.string.question_oceans, true),
new Question(R.string.question_mideast, false),
new Question(R.string.question_africa, false),
new Question(R.string.question_americas, true),
new Question(R.string.question_asia, true),
};
private int mCurrentIndex = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
mQuestionTextView = (TextView) findViewById(R.id.question_text_view);
mTrueButton = (Button) findViewById(R.id.true_button);
mTrueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkAnswer(true);
}
});
mFalseButon = (Button) findViewById(R.id.false_button);
mFalseButon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkAnswer(false);
}
});
mNextBuuttonn = (Button) findViewById(R.id.next_button);
mNextBuuttonn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
updateQuestion();
}
});
mPrevButton = (Button) findViewById(R.id.prev_button);
mPrevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentIndex = Math.abs((mCurrentIndex - 1) % mQuestionBank.length);
updateQuestion();
}
});
updateQuestion();
}
private void updateQuestion(){
int question = mQuestionBank[mCurrentIndex].getTextResId();
mQuestionTextView.setText(question);
}
private void checkAnswer (boolean userPressedTrue) {
boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswertrue();
int messageResId = 0;
if(userPressedTrue == answerIsTrue) {
messageResId = R.string.correct_toast;
}
else {
messageResId = R.string.incorrect_toast;
}
Toast.makeText(this, messageResId, Toast.LENGTH_SHORT).show();
}
}
at com.bignerdranch.android.geoquiz.QuizActivity.updateQuestion(QuizActivity.java:88)
at com.bignerdranch.android.geoquiz.QuizActivity.onCreate(QuizActivity.java:82)
I tried code from archive, but it didn`t help