inflate和findViewById
2012-09-05 10:42
232 查看
inflate是用来找layout下布局文件,并实例化;而findViewById是找布局文件下的具体widget。
示例:其中this是Activity实例对象
//使用inflate
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View mainView = inflater.inflate(R.layout.main_view);
//使用findViewById
TextView txtHello = (TextView)this.findViewById(R.id.txtHello);
示例:其中this是Activity实例对象
//使用inflate
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View mainView = inflater.inflate(R.layout.main_view);
//使用findViewById
TextView txtHello = (TextView)this.findViewById(R.id.txtHello);
相关文章推荐
- inflate()和findViewById()
- findViewById()与Inflate()和setContentView()关系扯谈
- inflate方法与findViewById的区别
- The difference between LayoutInflater.inflate and findViewById
- findViewById()与Inflate()和setContentView()关系扯谈
- inflate, findViewById与setContentView的区别与联系
- inflate()和findViewById()函数的用法
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- inflate与setcontentview及findviewbyid(二)
- 有关Fragment的getActivity().findViewById,以及inflate与 findViewById 区别、setContentView和inflate的区别!!!
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- setContentView、findViewById 和 inflate 的区别?
- inflate方法与findViewById的区别
- android inflate之后findViewById返回null的解决方法
- setContentView和inflate调用findViewById的区别
- inflate() 和 findViewById
- findViewById的问题和inflate(0方法
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- inflate, findViewById与setContentView的区别与联系 分类: H1_ANDROID 2014-04-18 22:54 1119人阅读 评论(0) 收藏
- inflate和findViewById方法对比