开发者社区 问答 正文

在 intent 中添加一个 arraylist

我想发送一个 arraylist 到 parent activity
screenshot
下面是简单的代码
screenshot
如何在 intent 中添加,还有如何从 parent activity 里检索?
screenshot

展开
收起
蛮大人123 2016-02-18 13:30:40 2209 分享 版权
2 条回答
写回答
取消 提交回答
  • 用Serializable
    2019-07-17 18:43:53
    赞同 展开评论
  • 我说我不帅他们就打我,还说我虚伪
    public class Receipt implements Serializable{
        public String referenceNo;
        public byte[]   image;
        public String comments;
        public long   createdOn;
        public long   updatedOn;
        //...
    }
    
    //Put the list in the intent
    List<Receipt> list = ...
    Intent data = new Intent();
    data.putExtra("tag", list);
    
    //Read the list from the intent:
    list = (List<Receipt>) data.getSerializableExtra("tag");
    2019-07-17 18:43:53
    赞同 展开评论
问答地址: