Turn the difference getchildfragmentmanager Getsupportfragmentmanager

Source: Internet
Author: User

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.

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

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 ());

Turn the difference getchildfragmentmanager Getsupportfragmentmanager

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.