duplicated id with fragment

后端 未结 3 970
情歌与酒
情歌与酒 2020-12-01 07:00

I\'m trying to applicate drawernavigation (my first fragment is a map & the others are just some fragments with simple layouts).So it runs fine & I can navigate betw

3条回答
  •  不知归路
    2020-12-01 07:39

    use this

    
    

    and override method onDestroyView() and Just put this code in onDestroyView()

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

提交回复
热议问题