Android - SupportMapFragment with GoogleMaps API 2.0 giving IllegalArgumentException

前端 未结 11 1741
情书的邮戳
情书的邮戳 2020-11-27 04:17

I am trying to use the latest Map API 2.0 provided for Android. I am using the Support Library as I want to support Android 2.2. Following is my code:

Main A

11条回答
  •  醉梦人生
    2020-11-27 04:53

    You can fix this, if you delete all nested fragments in onDestroyView(). Don't know if it is a proper solution.

    public void onDestroyView() {
       super.onDestroyView(); 
       Fragment fragment = (getFragmentManager().findFragmentById(R.id.map));   
       FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
       ft.remove(fragment);
       ft.commit();
    }
    

    And inflating them as usual in onCreateView()

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.map, container, false);
    }
    

提交回复
热议问题