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) Improving Our Code Adding More Colors

Samantha Mar
Samantha Mar
691 Points

java.lang.String error ?

In my Activity class: int color = mColorWheel.getColor(); and in my ColorWheel class: return colorAsInt;

are red squiggly lined and I get the error "java.lang.String error" for both, and the compiler says "required: int"

Please help! :)

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Samantha;

Welcome to Treehouse!

Without seeing all of your code this is just an educated guess. :wink:

You are asking your variable color, which you are declaring as type int to be assigned to a String object. That would be like saying 5 = purple. In the world of computers that will typically give you an error because they are different types. There is a method, which Ben talks about in the video around the 4:05 mark which lets you convert a color into an int value, parseColor().

The parseColor() method takes a hexadecimal String argument, or a few actual colors as strings (see the documentation) and then returns an integer value of the color. Perhaps in your Activity class you are missing that method in your line of code?

Post back if you are still stuck or have questions.

Happy coding,
Ken