发送之前数据结构:
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>>;
这是为什么呢?
大家讲道理2017-04-17 17:14:41
LinkedHashMap is a subclass of HashMap. Have you tried explicit type conversion?
PHPz2017-04-17 17:14:41
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.