我如何传递一个对象:ArrayList中从一个活动到另一个
How can I pass a Object: ArrayList from one Activity to another?
看来,意图不能只是ArrayList中持有定制的。
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!
如果你想避免使用静态成员砍,你的自定义类, SingleExamResult
,必须实现 Parcelable
接口:
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