【发布时间】:2018-11-27 17:12:01
【问题描述】:
我需要帮助将 OpenWeatherMap 图标转换为实际的 png 图像。
到目前为止,我已将图标代码 (iconName) 检索到文本视图中,并为完整图像 url (iconUrl) 创建了字符串。
String iconName = JSONWeather.getString("icon");
String iconUrl = JSONWeather.getString(IMG_URL + iconName +".png");
但我很难将此网址插入图像视图。
我收到的错误是
E/Utils:解析地震 JSON 结果时出现问题 org.json.JSONException:https://openweathermap.org/img/w/04n.png 没有值
我看到在这里可以使用毕加索,但是下面的代码为我显示红色的 viewHolder,我不知道需要添加什么来解决这个问题。
Picasso.with(viewHolder.itemView.getContext()).load(iconUrl).into(viewHolder.condIcon)
<ImageView
android:id="@+id/condIcon"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
/>
ImageView iconView = findViewById(R.id.condIcon);
iconView.setImageURI(Uri.parse(earthquake.iconUrl));
【问题讨论】:
标签: java android icons openweathermap