我需要你的帮助,我不明白发生了什么?putExtra treeMap返回HashMap不能转换为TreeMap android
我想送2个活动之间一个TreeMap,代码是这样的:
class One extends Activity{
public void send(){
Intent intent = new Intent(One.this, Two.class);
TreeMap<String, String> map = new TreeMap<String, String>();
map.put("1","something");
intent.putExtra("map", map);
startActivity(intent);
finish();
}
}
class Two extends Activity{
public void get(){
(TreeMap<String, String>) getIntent().getExtras().get("map");//Here is the problem
}
}
这将返回到我的HashMap不能被转换为TreeMap的。什么
对于所发生的事情的血淋淋的细节,请参阅我的答案在这里:http://stackoverflow.com/questions/12300886/linkedlist-put-into -intent-extra-gets-recast-to-arraylist -in-retrieval -in-nex/12305459#12305459 –