Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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