17th Chapter Fragment
1. Add the LAYOUT-SW600DP directory to the Res directory to store the layout file of the screen size of 7 inches and more. 10 inch or more flat plate with SW720DP. If it's a smaller screen, like 480*800, use SW480DP
2, in the layout file directly in the <fragment> tag embedding time, to mark the class attribute, that is similar to class = "com.abc.MyFragment" can also be used Android:name, and the class attribute exactly the same
3. The host activity of the current fragment can be obtained through the fragment.getactivity () method. Note that all fragment controls in the activity, as well as the activity controls, are available through Activity.findviewbyid.
4, the intent carries the data and obtains the data the method Intent.putextra ("detail", data); Get Data with Getintent (). Getextra (). GetString ("detail");
5. Dynamic creation and addition of fragment
Fragmentmanager Fragmentmanager = Getfragmentmanager (); Create Manager
Fragmenttransaction fragmenttransaction = Fragmentmanger.begintransaction (); Transaction opened by manager
Customfragment customfragment = new Customfragment (); Create a custom fragment
Fragmenttransaction.add (r.id.parentcontainer,customfragment); Add fragment by transaction
Fragmenttransaction.commit (); Commit a transaction
Android Development Authority Guide Reading notes