Several problems encountered in the use of Android Fragment

    Several problems encountered in the use of Android Fragment                          

                   First, let’s talk about the inflate method of the LayoutInflater object. In this method, there are three parameters (int resource, ViewGroup root, boolean attachToRoot). Resource is the layout file to be instantiated, root is the parent layout of the layout file, and attachToRoot is whether to Resource is added to root, the default is true, if it is set to false, it will not be added to root.

            When using Fragment, the parameter attachToRoot should be set to false in the onCreatView, otherwise an error will be reported, telling you that the Fragment has specified the parent View. as follows:       

        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View v = inflater.inflate(R.layout.livelist, container,false);

         return v;

}

Guess you like

Origin blog.csdn.net/skateboard1/article/details/44262799