I want to pass an ArrayList of string arrays from one activity to another in Android.
How can I use intent
or bundle
? Please consider that intent.putStringArrayListExtra
is not working in this case, because it is not for string arrays.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
This Problem have a simple solution you can simply declare ArrayList public & static in your First activity and then call it in another one.
In your First Activity
In second Activity
I'm not familiar with if this is doable or not as things stand with the Bundle class so i would implement a custom object to house your ArrayList. this is a good clean solution for housing other common data that you would need to access in both activities
and then in your Activity:
also i would suggest using an arraylist of arraylists instead of an arraylist of arrays
Not sure what you mean by "ArrayList of string arrays"
If you have string array then check the below link
Passing string array between android activities
http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
ArrayList implements
Serializable
You can use intents
To retrieve
public Intent putStringArrayListExtra (String name, ArrayList<String> value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Parameters
Returns
To pass ArrayList of String array
To retrieve
So you want to pass a List of String arrays, not a List of Strings, right? Since
ArrayList
is serializable, you can add it pretty easy: