Setcontentview:
1. Commonly used constructors:
1) setcontentview (int layoutresid) 2) Setcontentview (view view) 3) Setcontentview (view view, Viewgroup.layoutparams params)
2. Usage
1) Setcontentview (R.layout.main);
2) Layoutinflater Inflater = (layoutinflater) getsystemservice (Context.layout_inflater_service);
true);
Setcontentview (view);
3. Application scenarios for two uses:
Setcontentview () Once called, Layout will display the UI immediately, and inflate will only form an object that is implemented in the view class, and then displayed with the Setcontentview (view) when necessary.
The interface is typically displayed in activity through Setcontentview (), but dynamic loading is required if you want to set up the control layout in a non-activity way.
Layoutinflater:
Three ways to get Layoutinflater instances
1. Layoutinflater inflater = Getlayoutinflater (); // call Activity Getlayoutinflater ()2. Layoutinflater Localinflater = (layoutinflater) context.getsystemservice (Context.layout_inflater_service); 3. Layoutinflater Inflater = layoutinflater.from (context);
In fact, these three ways are essentially the same, from the source can draw the conclusion : The final essence of these three ways is called context.getsystemservice ().
Android Setcontentview and Layoutinflater