I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides getView()). This custom adapter uses as its backend a List<CustomObject>. The elements in this List are retrieved from the network, so I would like to save it in onSaveInstanceState(). However, I can’t find a way to put a List<E> in a Bundle. I’m thinking this is a common task, saving a custom array in the instance state. How do other people do it?
I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides
Share
You can’t serialize a
List<E>, you need to transform to anArrayand use that when you pass a serialized object. Then read out the array and transform into a list. See this questions, it’s about sortedset serializationEalso must be serializable.Look into
.toArrayorputStringArrayeitherputStringArrayList