【发布时间】:2016-09-18 09:39:52
【问题描述】:
我有这个数组列表,我像这样从 json 解析列表项,
List<String> imageUrls;
imageUrls = new ArrayList<>();
JSONArray imageArray = response.getJSONObject(feedKey).getJSONArray(entryKey).getJSONObject(i).getJSONArray(imageKey);
for (int j = 0; j < imageArray.length(); j++) {
String imageList = imageArray.getJSONObject(j).getString(labelKey).toString();
imageUrls.add(imageList);
}
appShowModule.setAllimage(imageUrls);
然后我尝试在另一个活动中这样做,
intent.putStringArrayListExtra("list", appShowModule.getAllimage());
但是“appShowModule.getAllimage()”是错误的!我怎样才能收到它?
【问题讨论】:
-
我编辑我的问题
-
你总是需要明确你的错误。
getAllimage()返回什么?如果它返回一个通用的List,您需要将其转换为ArrayList<String>才能在那里使用它 -(ArrayList<String>) appShowModule.getAllimage()。链接的副本在下一个Activity中有如何检索它的示例。 -
公开列表
getAllimageurl() { return Allimageurl; } -
在模块中我有这个私有 List
Allimage = new ArrayList (); public List getAllimage() { return Allimage;} public void setAllimage(List allimage) { Allimage = allimage; }
标签: android arrays json arraylist