您應該製造DateRTO
Parcelable
- 這應該是微不足道的。然後,
Map<String, List<RateDTO>> map;
public void writeToParcel(Parcel out, int flags) {
out.writeInt(map.size());
for (Map.Entry<String, List<RateDTO>> entry : map.entrySet()) {
out.writeString(entry.getKey());
final List<RateDTO> list = entry.getValue();
final int listLength = list.size();
out.writeInt(listLength);
for (RateDTO item: list) {
out.writeParcelable(item, 0);
}
}
}
private MyParcelable(Parcel in) {
final int size = in.readInt();
for (int i = 0; i < size; i++) {
final String key = in.readString();
final int listLength = in.readInt();
final List<RateDTO> list = new ArrayList<RateDTO>(listLength);
for (int j = 0; j < listLength; j++) {
final RateDTO value = in.readParcelable(ParentClass.class.getClassLoader());
list.add(value);
}
map.put(key, list);
}
}
我還沒有測試代碼,但我相信它應該接近OK。請注意,如果你的地圖比較大,這個解決方案並不是特別好。
你到目前爲止嘗試過什麼嗎? – curtisLoew