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 trialVeasna Mam
263 PointsCan not resolve symbol occur.
When I wrote out the Textview and Button it become red what does this mean how do I fix it and it says cannot resolve symbol when i place my mouse on on Textview and button bellow I copy and paste the code.
// Declare our View variables and assign them the Views from the layout file
Textview factLabel = findViewById();
} Button showFactButton;
2 Answers
Steve Hunter
57,712 PointsHi,
Your TextView
has a few issues:
- You've mistyped
TextView
- it needs a capital V - The returned value from the
findViewById()
needs casting; add(TextView)
beforefindViewById
- Last, you need to reference the
id
. That is probably something likeR.id.factLabel
or something
Your button code will need something similar too.
You'll end up with something similar to:
TextView factLabel = (TextView) findViewById(R.id.factTextView);
Button showFactButton = (Button) findViewById(R.id.showFactButton);
Steve.
Corey Moten
6,081 PointsAlso if you are getting a cannot resolve symbol error from the TextView and/or Button, sometimes you just need to organize your imports so that TextView and Button are imported into the class. Once you include those imports they should turn from red to green.