【问题标题】:Android: How to pass ArrayList<customObject> between Activities?Android:如何在活动之间传递 ArrayList<customObject>?
【发布时间】:2010-10-15 03:39:00
【问题描述】:

如何将 Object: ArrayList 从一个 Activity 传递到另一个?

似乎intent 不能保存除ArrayList 之外的自定义。

作为一种 hack,我使用静态成员:

staticResultList = new ArrayList<SingleExamResult>(m_examResults);

并通过以下活动获取它:

m_examResults = DoExam.staticResultList;

这显然不是正确的方法,任何“常见”方法?非常感谢!

【问题讨论】:

    标签: android android-activity android-intent


    【解决方案1】:

    如果您想避免使用静态成员 hack,您的自定义类 SingleExamResult 必须实现 Parcelable 接口:

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

    【讨论】:

    猜你喜欢
    • 2013-07-30
    • 2012-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-01
    • 2023-03-23
    相关资源
    最近更新 更多