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 trialAlex Ziv
1,384 PointsAndroid Studio is telling me it cannot resolve method setText(java.lang.String). What have I done wrong?
Every thing else is according to the code showed in the video.
3 Answers
Zachary Green
16,359 PointsIs the object your using set text on a string and not some other object
Ben Junya
12,365 PointsCan you paste your code? Please show the entire method where you're having the problem.
Ryan Farber
5,329 PointsYou probably need to watch out on what needs to be capitalized and what shouldn't be capitalized
setText() != (does not equal) SetText() for example
Ben Junya
12,365 PointsBen Junya
12,365 PointsWe need to know more about your problem before we can help you answer it.
From what I'm inferring from the lesson, did you declare your TextView object?
somewhere in there, there should be:
TextView textview;
textview = (TextView) findViewById(R.id.textview); // or whatever ID has been placed on that textview
textview.setText("This is a string");
That should resolve, unless you're working from a fragment, which it should be:
textview = (TextView) getView().findViewById(R.id.textview);