Setcontentview:
1. Common constructor:
1) setcontentview (IntLayoutresid)
2) setcontentview (view)
3) setcontentview (view, viewgroup. layoutparams Params)
2. Usage
1) setcontentview (R. layout. Main );
2) layoutinflater Inflater = (layoutinflater) getsystemservice (context. layout_inflater_service );
View view = (View) Inflater. Inflate (R. layout. apploader,Null,True);
Setcontentview (View );
3. Use Cases:
Once setcontentview () is called, layout will immediately display the UI. Inflate will only form a ready-made object in the View class and display it with setcontentview (View) when necessary.
Generally, the interface is displayed through setcontentview () in the activity. However, if you want to set the layout of the control in a non-activity, you need layoutinflater to dynamically load it.
Layoutinflater:
Three methods for obtaining a layoutinflater instance
1. layoutinflater Inflater = getlayoutinflater ();//Call getlayoutinflater () of the activity ()
2. layoutinflater localinflater = (layoutinflater) Context. getsystemservice (context. layout_inflater_service );
3. layoutinflater Inflater = layoutinflater. From (context );
In fact, these three methods are essentially the same. We can draw a conclusion from the source code.: The three methods are called in essence.Context. getsystemservice ().