Fragment learning 1

Source: Internet
Author: User

A Fragment represents some behaviors in the Activity or some user interfaces. You can combine multiple Fragment in an Activity to create multiple UI panels. You can also reuse one Fragment in multiple activities. You can understand Fragment as a module of Activity. It has its own lifecycle, accepts its own input events, and you can add and delete Fragment when the Activity is running.

A Fragment must be embedded in an Activity and its lifecycle is directly affected by the lifecycle of its host Activity. For example, when the host Activity is paused, all Fragment in the Activity will be paused. The same is true when the host Activity is destroyed. However, when an Activity is running (in the resumed life state), you can operate on each Fragment separately, for example, adding or deleting an Activity. When you execute such a Fragment transaction, you can also add it to a back stack managed by Activity, A rollback stack entry in the Activity is a Fragment transaction record. This rollback stack allows you to roll Back a previous Fragment transaction by pressing the Back key.

When you add a Fragment as part of an Activity, it is active in the ViewGroup in the internal view hierarchy of the Activity and has its own layout. You can add a fragment to the Activity through xml and java code.


From thick and thin hair, water comes to the fore

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.