Fragment Loading Replace Add,show,hide,replace method

Source: Internet
Author: User

Replace the original fragment with the Replace method;

Use the Hide and show methods to show the fragment that have been added again.

You can use replace (r.id.layout,b). However, this leads to a problem where a will be destroyed after being replaced, and will call its life cycle function (Ondestoryview (), OnPause (), Ondestory ()).

If you frequently replace fragment will constantly create new instances, destroying the old ones and not reusing them.

Switching multiple times causes the view on the fragment to fail to load (the Oncreateview method is no longer called because the fragment instance is not created again after replace).

Summary: If the old fragment does not need to be reused, it can be destroyed using the Replace method.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. (reproduced please specify from Allencoder)

Fragment Loading Replace Add,show,hide,replace method

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.