Android: How to pass ArrayList betwe

2019-06-21 23:41发布

问题:

How can I pass a Object: ArrayList from one Activity to another?

Seems that intent cannot hold custom ones except ArrayList.

As a kind of hack, I use a static member:

staticResultList = new ArrayList<SingleExamResult>(m_examResults);

and Get it in the following Activity by:

m_examResults = DoExam.staticResultList;

It's not the correct way obviously, any 'common' approaches? Thanks a lot!

回答1:

If you want to avoid using the static member hack, your custom class, SingleExamResult, must implement the Parcelable interface:

http://developer.android.com/reference/android/os/Parcelable.html