Android intent 传递数组对象序列化

 1 实现序列化接口

package com.example.zcjfq2;

import java.io.Serializable;

public class SerInfo implements Serializable {
    private String Id;
    private String OldDocName;

    public SerInfo(String id, String olddocname){
        this.Id = id;
        this.OldDocName = olddocname;
    }
    public String getId() {
        return Id;
    }
    public String getOldDocName() {
        return OldDocName;
    }
    public void setId(String id) {
        this.Id = id;
    }
    public void setOldDocName(String olddocname) {
        this.OldDocName = olddocname;
    }

}

2 序列化

 ArrayList listObj = new ArrayList();
            
                    for (int i =0;i

3 接收并解析

ArrayList oldDocName = (ArrayList) getIntent().getSerializableExtra("oldDocName");
String id = oldDocName.get(1).getId();
        String name = oldDocName.get(1).getOldDocName();

 

你可能感兴趣的:(Android,开发)