inflate与findViewById
来源:互联网 发布:php关闭微信浏览器 编辑:程序博客网 时间:2024/05/18 00:34
总结的来说,inflate方法获得布局,findViewById方法获得布局下的控件
在活动类中,直接使用findViewById(),是获得指定布局(setContentView()设置的布局)下的控件
在非活动类中使用inflate方法获得布局
先获取LayoutInflater对象:
LayoutInflater mInflater=LayoutInflater.from(this);//LayoutInflater.from(getContext());
bView=mInflater.inflate(R.layout.XX_item,null);
或者直接
bView=LayoutInflater.from(this).inflate(R.layout.XX_item,null);
得到布局,我们就可以用bView.findViewById()得到相应布局文件里的某些控件。
例如:
TextView textView=(TextView) bView.findViewById(R.id.text_View);
textView.setText......
0 0
- inflate与findViewById
- findViewById()与Inflate()和setContentView()关系扯谈
- Android inflate方法与 findViewById 方法区别
- findViewById()与Inflate()和setContentView()关系扯谈
- inflate与setcontentview及findviewbyid(一)
- inflate与setcontentview及findviewbyid(二)
- inflate方法与findViewById的区别
- inflate方法与findViewById的区别
- inflate 方法与 findViewById方法的区别
- 有关Fragment的getActivity().findViewById,以及inflate与 findViewById 区别、setContentView和inflate的区别!!!
- inflate, findViewById与setContentView的区别与联系
- inflate, findViewById与setContentView的区别与联系
- inflate, findViewById与setContentView的区别与联系
- inflate和findViewById
- inflate() 和 findViewById
- inflate()和findViewById()
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- Swift编程基础(五):闭包
- 链表中环的入口结点
- 菜单
- 飛飛(二十二)求三角形周长和面积升级版
- Java通过内省操作JavaBean有什么作用?
- inflate与findViewById
- xcode插件管理目录
- java动态代理
- KVC与KVO详细介绍
- JVM---内存
- UVa 10305 Ordering Tasks
- github项目拖管
- Android 使用OKhttp 3.0以上版本上传文件或图片(MultipartBuilder已不可用)
- modelAndView传值给JSP