Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to pass ArrayList<customObject> between Activities?

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!

like image 576
herbertD Avatar asked Nov 06 '22 07:11

herbertD


1 Answers

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

like image 82
Tyler Treat Avatar answered Nov 09 '22 05:11

Tyler Treat