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!
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
Tom Finet
7,027 PointsAdding Weather Icon
I am trying to get the weather icon id so that I can display it. For some reason it does not recognise the variables in the if statements.
Here is my code in CurrentWeather.java:
public int getIconId() {
//clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day, or partly-cloudy-night
int iconId = R.drawable.clear_day;
if (mIcon.equals("clear-day")) {
iconId = R.drawable.clear_day;
} else if (mIcon.equals("clear-night")) {
iconId = R.drawable.clear_night;
} else if (mIcon.equals("rain")) {
iconId = R.drawable.rain;
} else if (mIcon.equals("snow")) {
iconId = R.drawable.snow;
} else if (mIcon.equals("sleet")) {
iconId = R.drawable.sleet;
} else if (mIcon.equals("wind")) {
iconId = R.drawable.wind;
} else if (mIcon.equals("fog")) {
iconId = R.drawable.fog;
} else if (mIcon.equals("cloudy")) {
iconId = R.drawable.cloudy;
} else if (mIcon.equals("partly-cloudy-day")) {
iconId = R.drawable.partly_cloudy;
} else if (mIcon.equals("partly-cloudy-night")) {
iconId = R.drawable.cloudy_night;
}
return iconId;
}
Here are the gradle build messages:
Error:(40, 32) error: cannot find symbol variable clear_day Error:(42, 32) error: cannot find symbol variable clear_day Error:(44, 32) error: cannot find symbol variable clear_night Error:(46, 32) error: cannot find symbol variable rain Error:(48, 32) error: cannot find symbol variable snow Error:(50, 32) error: cannot find symbol variable sleet Error:(52, 32) error: cannot find symbol variable wind Error:(54, 32) error: cannot find symbol variable fog Error:(56, 32) error: cannot find symbol variable cloudy Error:(58, 32) error: cannot find symbol variable partly_cloudy Error:(60, 32) error: cannot find symbol variable cloudy_night
What can I do to solve this?
1 Answer

Ozhan Saat
Courses Plus Student 4,002 PointsYour if statement is "if (mIcon.equals("clear-day"))" which means "if the icon equals a string".
Try
if (iconString.equals("clear-day"))