JSONArray arrayUpcoming = response.getJSONArray("results");
for (int i = 0; i < arrayUpcoming.length(); i++) {
JSONObject currentMovie = arrayUpcoming.getJSONObject(i);
String iconImage = null;
String background = null;
//images
if (currentMovie.has("image")) {
JSONObject objectImages = currentMovie.getJSONObject("image");
if (objectImages.has("icon_url")) {
iconImage = objectImages.getString("icon_url");
Toast.makeText(getActivity(), ""+ iconImage, Toast.LENGTH_SHORT).show();
}
if (objectImages.has("screen_url")) {
background = objectImages.getString("screen_url");
Toast.makeText(getActivity(), ""+ background, Toast.LENGTH_SHORT).show();
}
}
}
这没有意义,我的代码对我来说似乎很正常。抱歉,我不能给你更多关于上下文的见解,因为我似乎无法解决错误,比如 jsonobject $ 1 的初学者