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 trialCathy Zhou
452 PointsMy Android Studio cannot recognize factTextView nor showFactButton. It appears red instead of purple. Why is that?
What am I doing wrong? What should I add?
Cathy Zhou
452 PointsDavid, thanks for responding to me, my code is as follows: final TextView factLabel = (TextView) findViewById(R.id.factTextView); Button showFactButton = (Button) findViewById(R.id.showFactButton);
I believe I did exactly what the instructor did in the video, so I'm really unsure why studio can't recognize factTextView and showFactButton.
3 Answers
David Postlethwaite
9,355 PointsCathy, Check the id's in the activity_fun_facts.xml(the layout). In this file check the id's for the button and text view making sure the are spelled the same.
android:id="@+id/factTextView" android:id="@+id/showFact"
Cathy Zhou
452 PointsThanks! I think that was the issue, which makes sense.. now my program is having trouble resyncing everything.. so it's still red...
David Postlethwaite
9,355 PointsYour welcome, try building a clean project by selecting Build menu and then selecting Clean Project.
If you need any more help please let me know and if this has solved the problem don't forgot to mark best answer so everyone knows the questions has been answered.
David Postlethwaite
9,355 PointsDavid Postlethwaite
9,355 PointsCathy, Can you show your code for the onCreate class. If its red normally its a problem with the way you assigned the variable.