FragmentAdapter adapter = new FragmentAdapter(getActivity().getSupportFragmentManager(), fragments, titleList);
要改为
FragmentAdapter adapter = new FragmentAdapter(getChildFragmentManager(),fragments,titleList);
这个问题主要是fragment里面嵌套fragment造成各,再嵌套fragment里的类里面将获取FragmentManager的函数由getActivity().getSupportFragmentManager()换成getChildFragmentManager()函数就可以了。
网友评论