putExtra treeMap returns HashMap cannot be cast to TreeMap android

前端 未结 3 1211
星月不相逢
星月不相逢 2020-12-11 04:28

I need your help, I cannot understand what\'s happening?

I\'m trying to send a TreeMap between 2 activities, the code is something like this:

class O         


        
3条回答
  •  时光取名叫无心
    2020-12-11 04:47

    Instead of casting the result directly to a TreeMap, you can create a new TreeMap and use the putAll()-method:

    TreeMap myMap = new TreeMap;
    HashMap receivedMap = getIntent().getExtras().get("map");
    myMap.putAll(receivedMap);
    

提交回复
热议问题