The life cycle of fragments in Android

Source: Internet
Author: User

The life cycle of a fragment:

1. Onattach (): When a fragment is associated with an activity is called

2. Oncreateview (): The view used to create fragmentation

3. Onactivitycreated (): Called when the active OnCreate () method returns

4. Ondestroyview (): Called when the fragmented view is removed

5. Ondetach (): Called when fragmentation is removed from an active association


Trigger:

1. When the fragment was created: Onattach () onCreate () Oncreateview () onactivitycreated ()

2. When debris is visible: OnStart () Onresume ()

3. Debris goes backstage: OnPause () onStop ()

4. Fragment destroyed (the activity being destroyed): OnPause () onStop () Ondestroyview () OnDestroy () Ondetach ()

5. As with activities, you can use the bundle object to restore a fragmented instance in the following states: OnCreate () Oncreateview () onactivitycreated ()


The life cycle of fragments in Android

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.