Android Learning Note (iv) Fragment

Source: Internet
Author: User

1. From the Internet read a lot of fragment on the brief introduction, found that all are similar to the understanding, and all of them are roughly the same as the activity, did not say clearly the activity and fragment the specific relevance and difference, a lot of rubbish.

Here I also record my rubbish understanding:

On the life cycle of fragment, it really should be, as most people say, similar to activity and usage, but it's not enough to teach us how to use fragment.

Fragment is supposed to be part of the activity, more like a dynamic panel (perhaps actually a panel, which is just a loading force), which can be dynamically laid out, so fragment is only able to manage it independently of the activity on the interface. , but the response to the event, and other more complex operations are maintained by activity maintenance rather than fragment, so the fragment class is specifically responsible for its layout as part of the activity, and the event is still responsible for responding to the activity.

For example, the response to a button event in fragment requires that the corresponding response method be overridden in the activity (not the Fragment Class), and where the Setlistener method is used (this shows the fragment dependency, The fragment is included in the activity, and ultimately the button ID is obtained by activity)

Not to be continued ...

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.