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 an Interactive Story App (Retired) Finishing the User Interface Formatting Strings

Why 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

Please show an example.

protected 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.

Try these:

  1. Clean your project (Build - Clean Project)
  2. "Tools" -> "Android" -> "Sync Project with Gradle Files"
  3. Or just restart Android Studio?

Hope one works for ya!

My problem was that I made mistake in labeling my id for the relative layout. I fixed it. Thanks!