I want to pass a List<Map<String, String>> to another Activity. How to implement Parcelable for it?
I want to pass a List<Map<String, String>> to another Activity. How to implement Parcelable
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could extend
Mapand implementParcelablefor it. When writing to parcel, you could write elements count as a firstint, then iterate over entries and add them one after another like:When reading from parcel just read the first
int(that will be your entries count) and start a loop reading key and values one by one:And I believe there is a method to add list of parcelables to bundle, and since your map is a parcelable now it won’t be any problems.