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 a Simple Android App Basic Android Programming Accessing Views in Code: Assigning Variables

Can't find FactTextView

I set the mFactTextView as follows: mFactTextView = (TextView)findViewById(R.id.); It can not locate the FactTextView which I set in the global as follows: private TextView mFactTextView; I also set the prefix to m like in the video. I have also pressed 'Clean Project' which has been instructed in your other answers. Thank you

3 Answers

check res > layout > activity_fun_facts.xml. (in android view) should have [android:id="@+id/factTextView"] inside of [TextView]

think this as selector in html&css

Seth Kroger
Seth Kroger
56,413 Points

There's probably an error in your layout file preventing it from being built, which is preventing R.id.factViewText from being generated and picked up.

Beatriz Fuentes
Beatriz Fuentes
2,207 Points

make sure you have assigned an ID to the textview in the XML file or design view , once done make sure to use the same spelling , remember JAVA is case sensitive