Android Development 5-fragment and activity

Source: Internet
Author: User

First the Great God Summary link (summed up very well, there are examples, in order to look down on the good)

    • Android Fragment True Full parsing (on)
    • Android Fragment Real Full parse (bottom)
    • Android Fragment everything you should know
    • Android Fragment and activity

This article is mainly on-line data piling, and not too much collation. The collated version is then released.

Reasons for using Fragment
1. The switch between activity is not smooth
2. Modular activity, easy to do local animation (sometimes to get to this point to put multiple layouts into an activity inside, now can be replaced with multiple fragment, only when needed to load fragment, improve performance)

How to use
Fragmentactivity
1. Dynamically add or replace a fragment within an internal viewgroup
Fg
Ksmainfragment FRG = (ksmainfragment) cls.newinstance ();
Frg.setarguments (bundle);
Fragmenttransaction ft = Getsupportfragmentmanager ()
. BeginTransaction ();
Ft.replace (R.id.fcon_subview, FRG);
Mfocusfrage = FRG;
Ft.settransition (Fragmenttransaction.transit_fragment_fade);
Ft.commit ();

2. Define a label in layout, set the ID and the classname of the corresponding fragment

Android Development 5-fragment and activity

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.