发送之前数据结构:
private LinkedHashMap<Integer, LinkedHashMap<Integer, Integer>> selected = new LinkedHashMap<>();
通过
Bundle bundle = new Bundle();
bundle.putSerializable("data", selected);
传递到下一个activity之后,使用
getIntent().getBundleExtra(G.BUNDLE).getSerializable("data")
只能得到HashMap类型的数据结构,HashMap<Integer, HashMap<Integer, Integer>>;
这是为什么呢?
LinkedHashMap is a subclass of HashMap. Have you tried explicit type conversion?
Convert it into a json string, pass it and then convert it back.
LinkedHashMap does not implement the serializable interface, and its parent class HashMap does. Therefore, it is deserialized into a HashMap and can be forced to perform explicit type conversion when used.