Error inflating class fragment - duplicate id/illegalargumentexception?

后端 未结 7 878
梦毁少年i
梦毁少年i 2020-12-02 17:05

I\'m trying make an app that I\'m building take a search term from the main activity, return results, and then have the results be clickable such that a detail could be view

相关标签:
7条回答
  • 2020-12-02 18:04

    Let's try this out. I got the same problem and i fixed my problem using this code.

     View root;
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (root!= null) {
            ViewGroup parent = (ViewGroup) root.getParent();
            if (parent != null)
                parent.removeView(root);
        }
        try {
            root= inflater.inflate(R.layout.map_layout, container, false);
        } catch (InflateException e) {
            /* map is already there, just return view as it is */
        }
        return root;
    }
    
    0 讨论(0)
提交回复
热议问题