function:Used to instantiate an XML file into a specified view. Similar to Findviewbyid, the difference is that the layoutinflater found in the res file is not loaded or needs to be loaded dynamically, for the already loaded activity can use Findviewbyid to obtain the interface elements.
There are several ways to get Layoutinflater:
1. LayoutInflater inflater = getLayoutInflater();
//调用Activity的getLayoutInflater() Returns LayoutInflater The shared LayoutInflater.
2. LayoutInflater inflater = LayoutInflater.from(context);
//Obtains the LayoutInflater from the given context.
3. LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
//A LayoutInflater for inflating layout resources in this context
From the source to get three kinds of call Context.getsystemservice (), it according to name to obtain the corresponding object and then converted to the corresponding service object. Http://developer.android.com/reference/android/content/Context.html#getSystemService (java.lang.String) layout_ Inflater_serviceLayoutinflater Gets the view defined in the XML.
back to view:Use the Inflater method.
View view = inflater.inflate(R.layout.newview, null);
setContentView(view);//显示
From for notes (Wiz)
Layoutinflater function and use