1

我想将地图作为标题添加到 ListFragment。除非设备方向发生变化,否则一切似乎都运行良好。

ListFragment:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container == null) {
        return null;
    }

    mHeader = inflater.inflate(R.layout.map_header, null);      
    mMapView = (MapView) mHeader.findViewById(R.id.map);

    if (mMap == null) {
        mMap = mMapView.getMap();
        if (mMap != null) {
            mMap.setMyLocationEnabled(true);
        }      
    }

    return (LinearLayout) inflater.inflate(R.layout.my_fragment, container, false);
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {              
    super.onActivityCreated(savedInstanceState);
    mMapView.onCreate(savedInstanceState);

    mListView = getListView();
    mListView.addHeaderView(mHeader);                       

    String[] array = new String[] {"Android", "Android"};

    setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.list_item, R.id.text1, array));
}

错误:

Class not found when unmarshalling: org.holoeverywhere.widget.ListView$SavedState, e: java.lang.ClassNotFoundException: org.holoeverywhere.widget.ListView$SavedState
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.i906.mpt/com.i906.mpt.Main}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: org.holoeverywhere.widget.ListView$SavedState

如果我更改为,则不会发生此问题,mMapView.onCreate(null);但每次方向更改时地图都会重新加载。任何想法如何解决这个问题?

谢谢。

4

0 回答 0