java如何从OpenWeatherMap获取图标
我想得到openweathermap图标https://openweathermap.org/weather-conditions和http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b1b15e88fa797225412429c1c50c122a1图标是字符串值。我创建了imageView,但我不这么做
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, final int position, long id) {
String text = (String) listView.getItemAtPosition(position);
Factory.getInstance().havaModel(text,APPID_KEY).enqueue(new Callback<HavaModel>() {
@Override
public void onResponse(Call<HavaModel> call, Response<HavaModel> response) {
textView.setText(Float.toString((float) (response.body().main.temp-273.15)));
textView2.setText(Float.toString(response.body().coord.lon));
textView3.setText(Integer.toString(response.body().main.humidity));
textView4.setText(response.body().name);
imageView.getResources()
}
非常感谢。 你的建议对我很重要
# 1 楼答案
图标的文档在这里
http://openweathermap.org/weather-conditions
您将从JSON调用返回的对象中获取图标代码, 如你的问题所示,然后用它构建一个指向图标的url
您还可以使用图像加载库将图像加载到ImageView中,例如:-使用Picasso Image Library-
将此添加到您的构建中。格雷德尔档案-
然后使用下面的代码将图像加载到ImageView中-
希望这有帮助