Android fragment and Androidfragment

Source: Internet
Author: User

Android fragment and Androidfragment

Fragment can be used when you want to modularize the activity. We can say that fragment is a sub-activity.

The following are some important features of fragment:

1. fragment has its own layout, behavior, and lifecycle.

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

3. fragment can be used in multiple activities.

4. the lifecycle of fragment is related to its host activity.

5. fragment is added on api 11.

You can use the extens fragement class to create a fragment, and then add the <fragment> element to the layout file of an activity to declare the fragment.

For fragment, we need to know that we have a limit, because we can only display one activity on the screen at a time point, so we can't separate the screens and separate them to control them separately. But, we can combine multiple fragment on an activity and have their own layout, event processing, and complete lifecycle.

Below is a typical illustration of two different UI build methods:


Write the rest next time.

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.