我有这个数组列表,我从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());
但是&#34; appShowModule.getAllimage()&#34;是错误的!以及我如何收到它?
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以在Intent
:
public Intent putExtra(String name, CharSequence[] value)
答案 2 :(得分:0)
将List imageUrls更改为ArrayList imageUrls和 intent.putStringArrayListExtra(&#34;键&#34;,imageUrls);
答案 3 :(得分:0)
像这样发送你的清单
dir /b *.mp3
然后在您想要的活动中,收到像这样的列表
Intent i = new Intent(this, YourDesiredActiity.class);
i.putStringArrayListExtra("arrayListToSend",imageUrls);
startActivity(i);
然后,您可以在&#34; ArrayList<String> urlList = new ArrayList<String>();
Bundle extras = getIntent().getExtras();
if (extras != null) {
urlList.addAll(extras.getStringArrayList("arrayListToSend"));
}
&#34;
答案 4 :(得分:0)
将您的数组列表添加到您正在调用其他活动的意图
@RequestMapping(value = {"/edit-user-{id}"}, method = RequestMethod.GET)
public String editUser(@PathVariable Long id, ModelMap model) {
User user = userService.findById(id);
if (!user.getUsername().equals(context.getUserPrincipal().getName())) {
return "login";
}
model.addAttribute("userForm", user);
model.addAttribute("edit", true);
return "registration";
}
@RequestMapping(value = {"/edit-user-{id}"}, method = RequestMethod.POST)
public String updateUser(@Valid User userForm, BindingResult bindingResult, ModelMap model, @PathVariable Long id) {
model.addAttribute("edit", true);
model.addAttribute("success", "User " + userForm.getFirstName() + " " + userForm.getLastName() + " updated successfully");
userValidator.validate(userForm, bindingResult);
if (bindingResult.hasErrors()) {
return "registration";
}
userService.updateUser(userForm);
return "registrationsuccess";
}
获取活动中的数组列表。
intent.putStringArrayListExtra("list", yourarraylist);
startActivity(intent);
希望这会对你有所帮助。