Errors concerning the next button


#1

Heya. When I tried to implement the book’s code for the next button (Listing 2.8) I immediately got seven errors that I have not been able to determine the cause of.

The code in question:

[b]mNextButton [/b]= (Button)[b]findViewById[/b](R.id[b].[/b]next_button[b])[/b]; mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length; int question = mQuestionBank[mCurrentIndex].getQuestion(); mQuestionTextView.[b]setText[/b]; } }); }

(The errors are all on the first and last lines, I’ve bolded the highlighted parts)

And the errors:

Description Resource Path Location Type Syntax error on token ".", ... expected QuizActivity.java /GeoQuiz/src/com/bignerdranch/android/geoquiz line 58 Java Problem Syntax error on token ")", { expected after this token QuizActivity.java /GeoQuiz/src/com/bignerdranch/android/geoquiz line 58 Java Problem Syntax error, insert ";" to complete FieldDeclaration QuizActivity.java /GeoQuiz/src/com/bignerdranch/android/geoquiz line 58 Java Problem Return type for the method is missing QuizActivity.java /GeoQuiz/src/com/bignerdranch/android/geoquiz line 58 Java Problem Syntax error, insert "AssignmentOperator Expression" to complete Expression QuizActivity.java /GeoQuiz/src/com/bignerdranch/android/geoquiz line 64 Java Problem setText cannot be resolved or is not a field QuizActivity.java /GeoQuiz/src/com/bignerdranch/android/geoquiz line 64 Java Problem Syntax error on token "mNextButton", VariableDeclaratorId expected after this token QuizActivity.java /GeoQuiz/src/com/bignerdranch/android/geoquiz line 58 Java Problem


#2

Hmm. I’m not sure what’s going on there. It almost looks like your code listing isn’t in the right place in your class.