Trouble with challenge 1



Okay, i’ve tried searching for a solution but am still confused. I’m having trouble with the first challenge on page 49: Add a Listener to the TextView.

I thought of creating a private function called displayQuestion as follows and increasing the array by 1 as follows:
private void displayQuestion(){
int question = mQuestionBank[mCurrentIndex].getQuestion();

and then calling displayQuestion in:

mNextButton = (Button)findViewById(;
mNextButton.setOnClickListener(new View.OnClickListener() {

		public void onClick(View v) {
			//mCurrentIndex = (mCurrentIndex - 1) % mQuestionBank.length;
			mCurrentIndex = mQuestionBank.length - mCurrentIndex;

but had no luck.

Okay so after a few attempts and some code changes, I am able to go back through the previous elements in the array however I know there is a stopper that is not letting me iterate back through all the elements. Perhaps, I should put it in a loop… hmmm… just came to me. may try that…
I’ve always had trouble with arrays. I don’t know why…



In your code above, you’re decrementing the question id in displayQuestion. I imagine that would cause some weird issues.