Fragment life cycle

Source: Internet
Author: User

The life cycle of the fragment is done in the following order: Onattach (), OnCreate (), Oncreateview (), onactivitycreated (), OnStart (), Onresume (), OnPause (), OnStop (), Ondestoryview (), Ondestory (), Ondetach ().

The life cycle of the fragment is dependent on the activity's life cycle, and the life cycle of the fragment can run independently only when the activity is in the resumed state.

Onattach (): Binds the activity to get the value that the activity passes over

Oncreateview (): Create a view for fragment or load a layout, update the layout

Onactivitycreated (): Called when the OnCreate () method in activity is called

Ondestoryview (): Remove the Fragment layout

Ondetach (): Unbind with activity

When creating the Fragment Experience Onattach (), OnCreate (), Oncreateview (), onactivitycreated ()

Fragment is visible to the user through OnStart (), Onresume ()

Fragment Experience OnPause (), OnStop () when not visible to users

Fragment Destruction Experience OnPause (), OnStop (), Ondestoryview (), Ondestory (), Ondetach ()

Remove a ListView border

Android:divider= "#ffffff"

Fragment life cycle

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.