您的位置:首页 > 其它

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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  service layout