Code acting *odd*


#1

Hey, so I just wrote our first little app from the book, the GeoQuiz app. I thought everything was working out but apparently I’m wrong. So my problem is that it seems like my “next” and “true” buttons are switched… When I click “true” it just grabs a new question with no toast or anything. When I click “next” it does a toast as if it were a “true/false” button and then grabs a new question.

I downloaded the android.zip to compare my code to what they have, but unfortunately it only contains the code for the app from only the first few sections of the book. Nothing about the next button or TrueFalse.java model layer.

I’ve been looking over my code to see what could be wrong but I’m just not seeing it… from what I described you’d imagine that maybe I had just switched the id’s of the next and true buttons but that’s not the case, at least I don’t think it is…

Here’s some of my code: (pretty much straight from the book )…

[code] mTrueButton = (Button) findViewById(R.id.true_button);
mTrueButton.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			checkAnswer(true);

		}
	});[/code]

[code] mNextButton = (Button) findViewById(R.id.next_button);
mNextButton.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
			updateQuestion();
		}
	});

	updateQuestion();[/code]

#2

Have you looked at your layout file?


#3

Got it working, I wasn’t updating question after clicking true or false.