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 Accessing Views in Code

TextView problem

My Android Studio separates fact and textView into two different words. My code is the following...

TextView factLabel = (TextView)findViewById(R.id.fact textView);

The error is cannot resolve symbol fact.

3 Answers

The added "textView" in the resource id is confusing the system. It is not needed. I believe it should be:

TextView factLabel = (TextView)findViewById(R.id.fact);

I still get a following error that says cannot resolve fact. Am I doing something wrong in the previous steps?

From what I can tell you are working on the Build a Simple Android App, Basic Programming, Initializing a button challenge. In that challenge they want you to initialize a button similar to the TextView example they have already provided. They already declare showFactButton as a Button. All you need to do is to point it to the Button view. The answer is below.

    Button showFactButton = (Button) findViewById(R.id.showFactButton);