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 (2014) Basic Android Programming Adding the onClick() Method

Alex Ziv
Alex Ziv
1,384 Points

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

Ben Junya
Ben Junya
12,365 Points

We 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);

3 Answers

Zachary Green
Zachary Green
16,359 Points

Is the object your using set text on a string and not some other object

Ben Junya
Ben Junya
12,365 Points

Can you paste your code? Please show the entire method where you're having the problem.

You probably need to watch out on what needs to be capitalized and what shouldn't be capitalized

setText() != (does not equal) SetText() for example