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
View view = inflater.inflate(R.layout.newview, null);
setContentView(view);//显示
原文:http://www.cnblogs.com/fruitbolgs/p/4173600.html