Error inflating class fragment: Duplicate id , tag null, or parent id with another fragment

我只是一个虾纸丫 提交于 2019-11-29 04:21:40
Fenil

I solved it now!

The another solution is linked answer worked for me well.

https://stackoverflow.com/a/14484640/3960528

As explained there, I added onDestroyView() in `fragment that contains maps.

@Override
public void onDestroyView() {
    super.onDestroyView();
    MapFragment f = (MapFragment) getFragmentManager()
                                         .findFragmentById(R.id.mymap);
    if (f != null) 
        getFragmentManager().beginTransaction().remove(f).commit();
}

This fixed my problem:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    if(rootView==null){
        rootView = inflater.inflate(R.layout.MapFragment, container, false);
    }
    return rootView;
}

More here: https://colinyeoh.wordpress.com/2014/07/20/android-mapfragment-exception-when-clicked-twice/

Caio Nilton
MapFragment f = (MapFragment) getFragmentManager()
                                         .findFragmentById(R.id.mymap);
    if (f != null) 
        getFragmentManager().beginTransaction().remove(f).commit();

Actually you don't need to use this inside an onDestroyView. My case was to remove an inflated layout with a SupportMapFragment, and that was it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!