put Serializable List to Bundle - Android Android OS

Android examples for Android OS:Bundle Put

Description

put Serializable List to Bundle

Demo Code


//package com.java2s;
import android.os.Bundle;

import java.io.Serializable;
import java.util.ArrayList;

public class Main {
    public static void putSerializableList(Bundle bundle,
            ArrayList<? extends Serializable> list, String key) {
        if (list == null) {
            return;
        }/*from ww w  .  j  a  v  a2s .c  om*/
        bundle.putInt(key + "size", list.size());
        for (int i = 0; i < list.size(); i++) {
            bundle.putSerializable(key + i, list.get(i));
        }
    }
}

Related Tutorials