Android's Fragment

Source: Internet
Author: User

When you want to design your activity in a modular way, you can use fragmented fragment. We can say that fragment is a sub-activity.

Here are some important features of fragment:

1.fragment has its own layout, its own behavior, and its own life cycle.

2. When an activity is running, you can add or remove fragment.

3.fragment can be used in multiple activities.

The life cycle of 4.fragment is related to its host activity

5.fragment is added on API 11.

You can create a fragment by Extens Fragement class, and then you can declare fragment by adding the <fragment> element to an activity's layout file.

For fragment, it's important to know that we have a limit because we can only show one activity on the screen at a point in time, so I don't want to split the screen and then separate control them separately. But, we can combine multiple fragment on one activity and have their own layout, event handling, and complete life cycle.

Here's a typical illustration of two different ways to build a UI:


The rest of the next time to write it.

Android's 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.