LayoutInflater的使用
2013-03-12 23:54
211 查看
LayoutInflater作用是将layout的xml布局文件实例化为View类对象。
获取LayoutInflater的方法有如下三种:
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.main, null);
LayoutInflater inflater = LayoutInflater.from(context); (该方法实质就是第一种方法,可参考源代码)
View layout = inflater.inflate(R.layout.main, null);
LayoutInflater inflater = getLayoutInflater();(在Activity中可以使用,实际上是View子类下window的一个函数)View layout = inflater.inflate(R.layout.main, null);
获取LayoutInflater的方法有如下三种:
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.main, null);
LayoutInflater inflater = LayoutInflater.from(context); (该方法实质就是第一种方法,可参考源代码)
View layout = inflater.inflate(R.layout.main, null);
LayoutInflater inflater = getLayoutInflater();(在Activity中可以使用,实际上是View子类下window的一个函数)View layout = inflater.inflate(R.layout.main, null);
相关文章推荐
- LayoutInflater作用及使用
- LayoutInflater类使用实例
- setContentView+LayoutInflater=完美切换页面(两者一定要同时使用,setContentView提高切换页面速度必看)setContentView的秘密----续上
- android中LayoutInflater的使用
- LayoutInflater作用及使用
- Android中LayoutInflater和MenuInflater的使用
- 关于LayoutInflater.from(context).inflate()的使用的问题
- LayoutInflater的使用方式
- 使用LayoutInflater与findViewById结果为null问题
- LayoutInflater的使用
- LayoutInflater的使用
- Android中LayoutInflater的使用
- LayoutInflater作用及使用
- View_01_LayoutInflater的原理、使用方法
- LayoutInflater作用及使用
- LayoutInflater的使用
- 【转】LayoutInflater作用及使用
- android LayoutInflater的使用
- ANDROID中LAYOUTINFLATER的使用
- LayoutInflater的使用和参数含义