Fragment nested Viewpager After switching data disappears Viewpager blank problem

Source: Internet
Author: User

First describe the phenomenon

After resolving

Before the online to find a lot of solutions, some netizens said to inherit Fragmentstatepageradapter replace Fragmentpageradapter I tried to try not to work. Later in the resolution of the following
This method is initialized Viewpager

private   void  init  () {fragmentslist = new  arraylis        T ();        Manager = Getfragmentmanager ();        Fragmentslist = new  arraylist<fragment> ();        Apply = new  Applystatusfrag ();        Audit = new  Auditstatusfrag ();        Fragmentslist.add (apply);        Fragmentslist.add (audit); adapter = new  myfragpageradapter (Getchildfragmentmanager (), fragmentslist); //for Getfragmentmanager;;; toggle fragment again back to previous fragment data disappears  Mpager.setcurrentitem (        Span class= "Hljs-number" >0 );        Mpager.setadapter (adapter);    Radiogroup_status.check (r.id.rdbtn_apply); }

Getchildfragmentmanager replaced the Getfragmentmanager problem is solved. The concrete principle is what, waits for the study.
Getfragmentmanager to the manager of the included fragment, and if fragment nested fragment, then Getchildfragmentmanager () will be used.
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.
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 ());

Hereby mark

Fragment nested Viewpager After switching data disappears Viewpager blank problem

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.