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
alainstudio
4,493 PointsI'm working on Android Stormy Weather App, and I wanted to use the metric units for degrees. Could you help me.
Weather App converting to celcius degrees.
2 Answers
Stephen Bone
12,359 PointsOK! Ignoring my first answer how about if you update your forecastUrl string to read as below:
I haven't worked through the Android Lists and Adapters course yet so I don't know if anything else has changed :)
String forecastUrl = "https://api.forecast.io/forecast/" + apiKey + "/" + latitude + "," + longitude + "?units=si";
Hope it helps!
Stephen
Stephen Bone
12,359 PointsHi alainstudio
You could update your getTemperature() method in the CurrentWeather class so it looks like below:
Basically just searched on Google for a method of converting Fahrenheit to Celsius and dropped it in.
public int getTemperature() {
return (int)Math.round((mTemperature-32) * 5 / 9);
}
Hope it helps!
Stephen
alainstudio
4,493 PointsHi Stephen, Thanks for your help. That works for the main tempuature but not for the 7 days. I notice on the Forecast.io the units in us or si (metric). Can we change this in the code?
alainstudio
4,493 Pointsalainstudio
4,493 PointsYou got it. Now we're talking. Thanks for your help.
Stephen Bone
12,359 PointsStephen Bone
12,359 PointsNo worries glad it helped!