相关疑难解决方法(0)

如何为包含List <List <String >>的类实现Parcelable?

我有一个工作Parcelable实现,除了我的Parcelable类中的所有字段List<List<String>>

class Employee implements Parcelable {

    List<List<String>> details;
    //.......

    protected Employee(Parcel in) {
        details = new ArrayList<List<String>>();
        // i know this is wrong just posting to clarify
        in.readList(details, List.class.getClassLoader());
        //......
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeList(details);
        //.....
    }

    public int describeContents() {
        return 0;
    }

    public static final Parcelable.Creator<Employee> CREATOR = 
            new Parcelable.Creator<Employee>() {
        public Employee createFromParcel(Parcel in) {
            return new Employee(in);
        }

        public Employee[] newArray(int size) {
            return new Employee[size];
        }
    };

} …
Run Code Online (Sandbox Code Playgroud)

android parcelable

9
推荐指数
1
解决办法
1590
查看次数

标签 统计

android ×1

parcelable ×1