2016-07-06 80 views
3

我正在嘗試使用Retrofit向Yahoo請求當前天氣。 我在通過城市時遇到了一個問題。我知道我必須使用@QueryAndroid - 翻新 - 查詢 - 雅虎天氣

雅虎查詢有點複雜,我不知道如何繼續。 這裏是我的代碼

@GET("yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20**text%3D%22brussels%2C%20be%22)%20and%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys") 

在這種複雜的查詢,我需要更新從城市參數 文本%3D%22brussels%2C%20be文本%3D%巴黎%2C%20FR例如。

任何幫助將不勝感激;

由於提前,

回答

3
@GET("yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20**text%3D%22{location}%2C%20be%22)%20and%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys") 
Call<response> groupList(@Path("location") String location); 

如果我正確理解你的問題,這應該工作。

+0

謝謝Tim。所以我在我的活動中,我需要通過城市變量,但這是我卡住的地方。如果我以這種方式傳遞:WeatherAPI.Factory.getmWeatherAPI()。getWeather(city).enqueue(new Callback - 據說我必須使用查詢: - /這裏是消息:不能有替換塊。動態查詢參數使用@Query。 – Isabelle