在 intent 中添加一个 arraylist -问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

在 intent 中添加一个 arraylist

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

展开
收起
蛮大人123 2016-02-18 13:30:40 2076 0
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
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载