Passing ArrayList Between multiple Activities

前端 未结 6 853
暖寄归人
暖寄归人 2020-12-10 06:11

I am trying to pass an ArrayList of Objects between multiple activities in my application. Is it possible to do this using an Intent using the setData() method?

6条回答
  •  粉色の甜心
    2020-12-10 06:35

    If the objects implement Parcelable you can use the putParcelableArrayList method like this:

    Bundle data = new Bundle();
    data.putParcelableArrayList("myArrayList", myList);
    Intent i = new Intent();
    i.putExtra("data", data);
    

    Hope that helps.

提交回复
热议问题