android.view.InflateException Error inflating class fragment

99封情书 提交于 2019-12-04 22:23:10

Add the following variable to your Fragment class:

private static View view;

Then in that same fragment class try replacing the onCreateView Method:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
if(view != null)
    {
        ViewGroup parent = (ViewGroup) view.getParent();
        if(parent != null)
        {
            parent.removeView(view);
        }
    }
    try
    {
        view = inflater.inflate(R.layout.fragment_places, container, false);
    }
    catch(InflateException e){
        // map is already there, just return view as it is
    }
    return view;

}

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