I'm trying to use Parceler to transfer variable of ArrayList>, but it always give error when running, just link intent.putParcelableArrayListExtra("votedetail", arrlist);. Searched and found no example, how to use it? Thank you in advance.
How to use Parceler with ArrayList<Map<String, String>>?
646 views Asked by bluehale At
3
There are 3 answers
0
On
Parceler is a library for serializing Parcelable objects. There is no need to use putParcelableArrayListExtra(), just use putParcelable():
List<Map<String, String>> value = new ArrayList<>();
// Fill out List
intent.putParcelable("votedetail", Parcels.wrap(value));
And you may deserialize in the onCreate of the receiving activity:
List<Map<String, String>> value = intent.getParcelableExtra("votedetail");
You can find examples on how to use it directly on the website: http://parceler.org/
Please take a look at the method's signature on Android Developer docs:
Intent putParcelableArrayListExtra (String name, ArrayList<? extends Parcelable> value)The objects in the
ArrayListhave to beParcelables. As far as I know, Android SDK implementations ofMap<K,V>(HashMap,SortedMap, etc) do not implementParcelable. You will have to write your own implementation which will also beParcelable.