Help passing an ArrayList of Objects to a new Activity

前端 未结 10 2212
眼角桃花
眼角桃花 2020-11-28 08:53

I have an arraylist of objects. ie ArrayList.

I want to pass this to a new Activity. I tried to use putParcelableArrayList but it has issues with the object. I remov

10条回答
  •  长情又很酷
    2020-11-28 09:14

    Very Easy way, try the following:

    bundle.putSerializable("lstContact", (Serializable) lstObject);
    lstObj = (List) bundle.getSerializable("lstContact");
    

    and also you will need to implement your Contact class from Serializable interface. ex :

    public class Contact implements Serializable{
       ...
       ...
       ...
    }
    

提交回复
热议问题