Next button not updating with next question


Hey there,

I’m up to Updating the Controller Layer and testing my next button but I cannot for the life of me work out why my next button isn’t updating with the next question in the array. I’ve gone over my code a few times and cant find any errors. Sorry for the code dump but maybe someone else can see some mistake I’ve made?


import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class QuizActivity extends Activity {

private Button mTrueButton;
private Button mFalseButton;
private Button mNextButton;
private TextView mQuestionTextView;

private TrueFalse[] mQuestionBank = new TrueFalse[] {
		new TrueFalse(R.string.question_oceans, true),
		new TrueFalse(R.string.question_mideast, false),
		new TrueFalse(R.string.question_africa, false),
		new TrueFalse(R.string.question_americas, true),
		new TrueFalse(R.string.question_asia, true),

private int mCurrentIndex = 0;

private void updateQuestion() {
	int question = mQuestionBank[mCurrentIndex].getQuestion();

protected void onCreate(Bundle savedInstanceState) {
    mQuestionTextView = (TextView)findViewById(;
    mTrueButton = (Button)findViewById(;
    mTrueButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Toast.makeText(QuizActivity.this, R.string.incorrect_toast, Toast.LENGTH_SHORT).show();
    mFalseButton = (Button)findViewById(;
    mFalseButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			Toast.makeText(QuizActivity.this, R.string.correct_toast, Toast.LENGTH_SHORT).show();
    mNextButton = (Button)findViewById(;
    mNextButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v) {
			mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;

public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);
    return true;



OK, I think I solved it myself. Seems my reference ID’s for the true and next buttons in were mixed up? I don’t know how that happened.

I just went into activity_main.xml, deleted the reference ID attributes then remade them. fixed the problem.