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

Hassan Osman
Hassan Osman
628 Points

textview factlabel = findViewById(R.Id.facttextview);

button showfactbutton; }

What are you trying to achieve?

2 Answers

Hello,

You need to cast your result from findViewById() to be the same as what you are trying to put it in. findViewById() returns a View which cannot be stored in a TextView variable. You cast a value by putting the new class in parenthesis before what you are casting. So you want it to look like

TextView factlabel = (TextView) findViewById(R.Id.facttextview); 

If you have any more questions feel free to ask.

Amish Garg
Amish Garg
976 Points

Hi hassan,

You are having a caps mistake in your code, and that code will never work. Type it this way : -

TextView factlabel = (TextView) findViewById(R.id.factTextView); 

Button showFactButton;

letters are case sensitive in android programming. So take care that you type the upper case letters in upper case. Always follow the code in videos exactly.

I hope your problem get solved, let me know that.