Problem with QuizActivity.java


#1

Totally new to programming, so please explain this to me like I’m a 3 year old, haha.

I keep on having problems in the QuizActivity.java folder. I keep on getting errors on the button variable name (don’t know if I described it correct here).

Here is the code I have:

	mPreviewButton = (Button)findViewById(R.id.preview_button);
	mPreviewButton.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v){
			 mCurrentIndex = (mCurrentIndex == 0) ? mQuestionBank.length-1 : mCurrentIndex -1;
	            updateQuestion();
	}
});

I can’t get rid of the error on this line: mPreviewButton = (Button)findViewById(R.id.preview_button);

The error message says that there are multiple markers at this line and then lists of 5 syntax errors. However, the syntax seems to be correct. I hope, haha.
I don’t know what other code this line may be interrelated with or how to fix the error. It’s the only thing that’s keeping me from testing the preview button, otherwise I think it should work. Any suggestion or recommendations would be awesome. Thank you for your help.


#2

Nevermind, solved it. It was outside of the onCreate bracket.


#3

Glad to see you fixed your problem!