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 trialReed Williams
3,323 PointsBuild a Simple Android App > Basic Android Programming > Accessing Views in Code
Build a Simple Android App > Basic Android Programming > Accessing Views in Code
Question 1: Why are my Rs red & how can I change this?
Pic: http://screencast.com/t/XRi9b5wpmD
Question 2: When I changed 'Hello World' to 'Did you know?' I did not get a warning as the video suggested, but in fact, got any error. How do I apply the proper resource?
Pic: http://screencast.com/t/hTv6moboWA
Pic: http://screencast.com/t/9cjVMaZA
When I try to run:
2 Answers
Yongshuo Wang
5,500 Points- Press Alt+Enter to get the suggestion from Android Studio.
- Run Build => Clean Project.
Michael Waihura
6,963 PointsHi Reed,
Qn 1. This is a syntax error.The android:id parameter for the TextView requires a value with the format @+id/[idOfView] in this case it should look like this android:id="@+id/factTextView" This tells android to create a new id for our textview.This happens during build and the view is automatically added to the R.java.In your case this is not happening and therefore the error with the R.Fix this in the activity_fun_facts.xml
Qn 2. from the messages view at the bottom of android studio,the error is still the id value."Resource id cannot be an empty string..." fixing the id value i.e android:id="@+id/factTextView" as above will also clear the error.Note:Any view that will be referenced in the FunFactsActivity.java requires an id.
let me know if that works
Reed Williams
3,323 PointsReed Williams
3,323 PointsALT + ENTER: http://screencast.com/t/umXhcWw0
Clean Project did not seem to work either.