# getFragmentManager与getChildFragmentManager，解决fragment白屏

getFragmentManager到的是activity对所包含fragment的Manager，而如果是fragment嵌套fragment，那么就需要利用getChildFragmentManager()了。
getFragmentManager到的是activity对所包含fragment的Manager，而如果是fragment嵌套fragment，那么就需要利用getChildFragmentManager()了。

getFragmentManager()和getChildFragmentManager()的使用，
getFragmentManager()是所在fragment 父容器的碎片管理，
getChildFragmentManager()是在fragment 里面子容器的碎片管理。

getFragmentManager到的是activity对所包含fragment的Manager，而如果是fragment嵌套fragment，那么就需要利用getChildFragmentManager()了。

Fragment嵌套Fragment要用getChildFragmentManager。

FragmentManager childFragmentManager = getChildFragmentManager();

The definition of getChildFragmentManager() is:

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

Meanwhile the definition of getFragmentManager() (or in this case getSupportFragmentManager()) is:

Return the FragmentManager for interacting with fragments associated with this fragment's activity.

Basically, the difference is that Fragment's now have their own internal FragmentManager that can handle Fragments. The child FragmentManager is the one that handles Fragments contained within only the Fragment that it was added to. The other FragmentManager is contained within the entire Activity.

In this case, what I'm guessing is you've added the Fragments to the Activity's FragmentManager. You get the child FragmentManager which doesn't contain what you are looking for. Thus you get the exception because it can't find the Fragment with the given ID because it's in a different FragmentManager.

也就是说child FragmentManager是对你应用的那个Fragment的，而FragmentManager是包含在activity中的，所以有可能出现找不到对应的fragment片段的情况而显示空白。

=============================================