0

I have an ArrayList of objects in one activity and I need this arrayList in another activity.

Is there a solution to transger this ArrayList? I know i can use intents for ArrayList of Strings but what's about the ArrayList of objects?

Thank you.

Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
  • 1
    I think this answers your question. http://stackoverflow.com/questions/6355787/how-to-pass-arraylist-from-one-activity-to-another – auy Apr 04 '12 at 13:45

1 Answers1

4

Complex types passed by means of Parcelable or do the serialization to another kind of primitive object that you can put to Intent's extras. see this question:

Help with passing ArrayList and parcelable Activity

and this tutorial:

Passing a list of objects between Activities

Community
  • 1
  • 1
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
  • Hi @imrankhan, I am trying to use the tutorial for parce an arrayList of objects but i have a roblem with the line b.putParcelableArrayList("categories", categories); when I am trying to parce. It says: The method putParcelableArrayList(String, ArrayList extends Parcelable>) in the type Bundle is not applicable for the arguments (String, ArrayList
    )
    – Milos Cuculovic Apr 05 '12 at 14:57
  • Ana,in example Category class contain an String category; and an ArrayList of Class Item.class – ρяσѕρєя K Apr 05 '12 at 16:12
  • @Ana : if you have any problem in implementing example from tutorial then download code from here [Passobjectlist](http://www.4shared.com/rar/8KPdYtYO/Passobjectlist.html ). i have created for you.thanks -:) – ρяσѕρєя K Apr 05 '12 at 16:30