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