viewpager+fragment problems with blank pages

Source: Internet
Author: User

Wrote three fragment, one click Jump Show Normal, if from the first jump directly to the third, the third page will appear blank interface.

The problem found: The original dynamic Access data page data is not displayed, the page is blank, that is, oncreateview every time the call caused, so that fragment each time the new view is set, and debugging found that the previous view is not recycled ... This leads to a new view that overrides the previously set view, which makes sense.

Combined with the information available on the Internet, there are 3 ways to solve this problem:

1 viewpager.setoffscreenpagelimit (num); num is your tab number,

2 in Oncreateview, determine whether fragment has added Contentview (the first time you load, you can save the view, load again, to determine whether the saved view is null), if the saved view is null, Return the new view, otherwise, remove the saved view from the parent view and return the view

3 rewrite public void Destroyitem (ViewGroup container, int position, object object), remove Super.destroyitem (container, Position, object);

viewpager+fragment problems with blank pages

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.