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 trialSharina V Jones
Courses Plus Student 1,847 PointsAccuWeather Icons
I just wanted to share the code I had using the AccuWeather API. It sends the info as an int, rather than a string.
My declarations
public class CurrentWeather {
...
private int weatherIcon;
...
public int getIconId(int weatherIcon) {
//https://developer.accuweather.com/weather-icons
//1. clear-day, 33. clear-night, 18. rain, 22. snow, 25. sleet, 32. windy, 11. fog, 7. cloudy
//3. partly-cloudy day, 39. partly-cloudy-night
int iconId = R.drawable.clear_day;
switch(weatherIcon) {
case 1:
iconId = R.drawable.clear_day;
break;
case 33:
iconId = R.drawable.clear_night;
break;
case 18:
iconId = R.drawable.rain;
break;
case 22:
iconId = R.drawable.snow;
break;
case 25:
iconId = R.drawable.sleet;
break;
case 32:
iconId = R.drawable.wind;
break;
case 11:
iconId = R.drawable.fog;
break;
case 7:
iconId = R.drawable.cloudy;
break;
case 3:
iconId = R.drawable.partly_cloudy;
break;
case 39:
iconId = R.drawable.cloudy_night;
break;
}
return iconId;
}
...
}