在我的程序中,我能够获取我的所有文本。但是在JSON数组中的JSOn中,有另一个具有图像URL的JSONArray。我正在使用JSON数组中的所有网址,但当我使用时,我没有收到任何回应。如何将我的ImageView替换为存储在URL中的URL。我的代码是在这里如何获取JSONArray值
private void parseResult(String result) {
try {
JSONObject response = new JSONObject(result);
JSONArray posts = response.optJSONArray("items");
GridItem item;
for (int i = 0; i < posts.length(); i++) {
JSONObject post = posts.optJSONObject(i);
String title = post.optString("itemname");
item = new GridItem();
item.setTitle(title);
JSONArray attachments = post.getJSONArray("itemimage");
if (null != attachments && attachments.length() > 0) {
JSONObject attachment = attachments.getJSONObject(0);
if (attachment != null)
item.setImage(attachment.getString(""));
}
mGridData.add(item);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
请发布您的logcat。 – Pankaj
显示'itemimage' JSONArray从服务器得到的字符串 –
HI @ρяσѕρєяK我正在获取我所有的项目图像url,但完成循环后,显示的东西 –