Android, google maps fragment and viewpager - Error inflating class fragment

后端 未结 2 1422
独厮守ぢ
独厮守ぢ 2021-02-05 16:27

i\'m trying to use google maps v2 within viewpager (fragmentpager) in a fragment. It works fine if i swipe to fourth fragment (view pager), but if i go back to the first fragmen

2条回答
  •  青春惊慌失措
    2021-02-05 17:06

    This worked for me.

    @Override
    public void onDestroyView() {
        // TODO Auto-generated method stub
        super.onDestroyView();
        try 
        {
            FragmentTransaction ft = getChildFragmentManager().beginTransaction();
            ft.remove(mapFragment);
            ft.commitAllowingStateLoss();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    

提交回复
热议问题