GeoQuiz keeps stopping. Open app again


#1

Hi, i’m on chapter 2 of the book android programming 3rd edition. at the time to test the application either on the emulator or the phone i get the message GeoQuiz has stop. The error i get is:

Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0

and below is where is pointing to:

          mNextButton = (Button) findViewById(R.id.next_button);
    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mCurrentIndex = (mCurrentIndex + 1) % mQuestionsBank.length;
            //int question = mQuestionsBank[mCurrentIndex].getTextResId();
            //mQuestionTextView.setText(question);
            updateQuestion();
        }
    });
    updateQuestion(); <------_this is the first error is pointing_
}
private void updateQuestion(){
    int question = mQuestionsBank[mCurrentIndex].getTextResId();
    mQuestionTextView.setText(question);  <------_this is the second error is pointing out_
}

Thanks in advance


#2

The error message is saying the value of question is zero. Is mCurrentIndex a local variable?


#3

Yes. mCurrentIndex is a local variable.