在savedInstanceState上获取ClassCastException

时间:2014-12-03 14:27:25

标签: android restore oncreate

在savedInstanceState上获取ClassCastException 我需要在调用恢复功能时获取位置ArrayList

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putSerializable("places", places);
}

private void restore(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        places = (ArrayList<HashMap<String,String>>) savedInstanceState.getSerializable("places"); 
    }
}

从onCreate调用恢复时获取java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList

0 个答案:

没有答案