摘要:Android - ViewPager + MapView - Unknow Source
我使用了ViewPager 跟 MapView的組合,
結果,發生不少錯誤是
MapView.onCreate(Unknow Source)
的問題。
找到一個比較能解決問題是下面這個連結
https://code.google.com/p/gmaps-api-issues/issues/detail?id=6237#c9
public void onSaveInstanceState(Bundle outState){
//This MUST be done before saving any of your own or your base class's variables
final Bundle mapViewSaveState = new Bundle(outState);
mapView.onSaveInstanceState(mapViewSaveState);
outState.putBundle("mapViewSaveState", mapViewSaveState);
//Add any other variables here.
super.onSaveInstanceState(outState);
}
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
final Bundle mapViewSavedInstanceState = savedInstanceState != null ? savedInstance.getBundle("mapViewSaveState") : null;
mapView.onCreate(mapViewSavedInstanceState);
//....
}
不過滑動時有遲頓遲頓的感覺,
後來覺得,可能MapView 加上 ViewPager,可能不適合,(好像也沒人這樣幹)
不然感覺效能很差,最後覺得該放棄使用。