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 trialStephanie Youstra
18,513 Points"Cannot resolve method 'findViewById(int)'" in FunFacts app
Typed in everything exactly as he has in the video; everything is in the "import" section. This still keeps throwing back the error, and the Alt+Enter suggestions are to:
- Add qualifier factLabel to method
- Create method 'findViewById'
- Split into declaration and assignment.
//Declare our View variables and assign them the Views from the layout file
TextView factLabel = (TextView) findViewById(R.id.factTextView);
Button showFactButton;
Copying and pasting from the code challenge threw out the same error. Everything else appears fine except that. Thanks!
3 Answers
Steve Hunter
57,712 PointsHi there,
Do you definitely have the following import in that file:
import android.widget.TextView;
Steve.
Stephanie Youstra
18,513 PointsSadly, Steve Hunter, I definitely do. Just double-checked -- actually, quintuple-checked probably, by this point. :-( Good thought, though -- thanks!
ada
Courses Plus Student 5,378 Pointsomg thank you!!
James Simshaw
28,738 PointsHello,
Is your class extending some form of Activity or View? I believe findViewById is only a part of the View and Activity classes and their descendents. If you are doing so, we'd need to see more of your code to be able to track down this issue fully.
Steve Hunter
57,712 PointsThat's a great idea. Good work!
Steve Hunter
57,712 PointsCan you push your project to Github or Zip the project and email it to me? I'll replicate the error here, as that's unlikely to be a local issue, and see what the fix is.
Steve.
Stephanie Youstra
18,513 PointsStephanie Youstra
18,513 PointsIf it matters, I'm using the newest version of Android Studio.