Binary XML file line #10: Error inflating class fragment

后端 未结 2 1112
一向
一向 2021-01-27 13:53

In my project I use three tab to show three activities in single screen. Tab 1 - Map
Tab 2 - Games
Tab 3 - Imageflipper
When I select tabs in series like Map--->Ga

2条回答
  •  梦如初夏
    2021-01-27 14:18

    Use of this code in TopRatedfragment.java solve this problem:

    private static View view;
    
    @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.map, container, false);
    } catch (InflateException e) {
        /* map is already there, just return view as it is */
    }
    return view;
    }
    

提交回复
热议问题