Getfragmentmanager to the manager of the included fragment, and if fragment nested fragment, then Getchildfragmentmanager () will be used.
Getfragmentmanager to the manager of the included fragment, and if fragment nested fragment, then Getchildfragmentmanager () will be used.
Encountered while using fragment
The use of Getfragmentmanager () and Getchildfragmentmanager (),
Getfragmentmanager () is the fragment management of the parent container where the fragment is located,
Getchildfragmentmanager () is the fragment management of the sub-container inside the fragment.
Getfragmentmanager to the manager of the included fragment, and if fragment nested fragment, then Getchildfragmentmanager () will be used.
Fragment nesting fragment to use Getchildfragmentmanager.
Encounter a problem, fragment put Viewpager,viewpager inside is fragment. First Entry no problem, again into the Viewpager fragment when the content is gone, data loss.
Fragmentpageradapter. Log found Fragmentpageradapter GetItem will not be called, has been unable to find the reason. The reply to the Internet finally found the answer.
Originally inside the fragment with or getfragmentmanager,fragment nested fragment, inside to use Getchildfragmentmanager.
Fragmentmanager Childfragmentmanager = Getchildfragmentmanager ();
Viewpager_adapter viewpager_adapter = new Viewpager_adapter (Childfragmentmanager, fragments); Fragmentpageradapter
The definition of IS getChildFragmentManager()
:
Return a private Fragmentmanager for placing and managing fragments inside of this Fragment.
Meanwhile the definition of is getFragmentManager()
getSupportFragmentManager()
:
Return the Fragmentmanager for interacting with fragments associated and this fragment ' s activity.
Basically, the difference is that Fragment's now has their own internal that FragmentManager
can handle fragments. The child Fragmentmanager is the one, handles fragments contained within only the Fragment, it was added to. The other fragmentmanager is contained within the entire Activity
.
In this case, what I'm guessing is your ' ve added the fragments to the Activity ' s fragmentmanager. You get the child fragmentmanager which doesn ' t contain what is looking for. Thus get the exception because it can ' t find the Fragment with the given ID because it's in a different fragmentmanage R.
That is, the child fragmentmanager is the fragment you apply, and Fragmentmanager is included in the activity, it is possible to find the corresponding fragment fragment of the situation and display blank.
=============================================
Msectionspageradapter = new Sectionspageradapter (getactivity (). Getsupportfragmentmanager ());
In fragment nested fragment words, do not use the above sentence ... will appear in the Viewpager. Some fragment will not load the situation ... Both Viewpager loading Fragment blank pages ....
So fragment inside nested fragment words: Must use Getchildfragmentmanager ();
Msectionspageradapter = new Sectionspageradapter (Getchildfragmentmanager ());
Getfragmentmanager and Getchildfragmentmanager, solving fragment white screen