Android fragment-manage Fragment

Source: Internet
Author: User

To manage fragment in an activity, you need to use the fragmentmanager object. You can obtain this object by calling the getfragmentmanager () method in the activity.

The fragmentmanager object can do the following:

1. Get the existing fragment in the activity, use findfragmentbyid () to obtain the fragment provided by the UI in the activity layout, or use the findfragmentbytag () method to obtain the fragment not provided by the UI;

2. Use the popbackstack () method to pop up the fragment from the rollback stack, similar to the user's rollback command;

3. Use addonbackstackchangedlistener () to register a listener for the rollback stack change.

For more information about these methods, refer to the fragmentmanager Class documentation.

As described in the previous chapter, you can also use fragmentmanager to open a fragmenttransaction object to execute transactions such as adding and deleting fragment.

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.