Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (2014) Basic Android Programming Adding the onClick() Method

When pressing Alt+Enter to fix the factLabel, I get different options to fix the error. There is no "make final" choice

The options I get are "Create local variable" "Create field" and "Create parameter"

2 Answers

I had trouble reproducing this error, but my best guess is that factLabel is not properly defined before you use it. What is the error that displays when you hover over the variable name? It should be "Variable 'factLabel' is accessed from within inner class, needs to be declared final". If you get something like "Cannot resolve symbol 'factLabel'" it means you haven't declared factLabel before trying to access it.

If you're sure you typed the variable declaration, make sure it is above the OnClickListener anonymous function.

Thanks Sara. I had defined the variable but had spelled it factlabel with a lower case rather than factLabel. So it couldn't recognize the variable I was referring to.