标签:使用 layout inf at t e 作用 layoutinflater out
作用:用来实例化一个XML文件到指定View中。与findViewById类似,不同的是LayoutInflater找的res文件下的没有被载入或需动态被载入,
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);//显示
标签:使用 layout inf at t e 作用 layoutinflater out
原文地址:http://www.cnblogs.com/fruitbolgs/p/4173600.html