Passing ArrayList with objects to new Activity?

前端 未结 6 682
猫巷女王i
猫巷女王i 2020-12-19 02:42

I\'m trying to pass an ArrayList from my first Activity to the next one. Basically, the first activity parses an XML file and creates an ArrayList with objects inside. What

6条回答
  •  太阳男子
    2020-12-19 03:23

    You can pass a String List using putStringArrayListExtra(String name, ArrayList value) if it is strings. Or, you could serialize List and then use putExtra(String name, Serializable value).

    If you don't want to/can't use the above, you could use a central util class with a static reference to the List. Just set it in your first Activity and get it in the second.

提交回复
热议问题