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 trialDawit Habtemariam
2,708 PointsWhy do all the areas in my code have red dotted lines under R?
I changed the ids for my choice buttons and then ran my code. It reported errors in the findByViewId method because it didn't recognize R. When I click alt+enter on top of it it just asks me to created classes, enum, fields and etc.
3 Answers
Jared M
3,680 PointsPlease show an example.
Dawit Habtemariam
2,708 Pointsprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
mNameField=(EditText)findViewById(R.id.nameEditText);
mStartButton=(Button)findViewById(R.id.startButton);
The Rs are red and AndroidStudio says it can't resolve the symbol.
Jared M
3,680 PointsTry these:
- Clean your project (Build - Clean Project)
- "Tools" -> "Android" -> "Sync Project with Gradle Files"
- Or just restart Android Studio?
Hope one works for ya!
Dawit Habtemariam
2,708 PointsMy problem was that I made mistake in labeling my id for the relative layout. I fixed it. Thanks!