动态载入Layout 与 论Activity、 Window、View的关系
2024-10-21 07:52:13
1)动态载入Layout的代码是
getWindow().setContentView(LayoutInflater.from(this).inflate(R.layout.main, null));
它等同于
setContentView(R.layout.main);
事实上
getWindow().setContentView(LayoutInflater.from(this).inflate(R.layout.main, null)) 是 setContentView(R.layout.main)
的底层实现
2)论Activity、 Window、View的关系
类似于MVC模式,Activity为控制器。Window为模型,View为真正的视图。
a。一个Activity 构造的时候一定会构造一个Window(PhoneWindow)。而且仅仅有一个
b,这个Window有一个ViewRoot(View / ViewGroup)
c,ViewRoot通过addView方法来加入View,如TextView,Button
d,这些View的事件监听,是由WindowManagerService来接收信息。而且回调Activity函数,
比方onClickListener。onKeyDown等。
最新文章
- RadioButton与CheckBox
- 《转载》使用org.w3c.dom.Element的setTextContent()、getTextContent()方法时出现编译错误
- 阅读ArrayBlockingQueue源码了解如何利用锁实现BlockingQueue
- android SDK下载及中文API地址
- Java期末设计(十三周)
- fontsize可以解决img标签插入图片之间的缝隙
- java.util.Properties
- SSRS2:Reporting Service 配置Service Account
- ubuntu下搭建lamp
- 动手学习TCP:4种定时器
- 蒙特卡洛法计算定积分—Importance Sampling
- 用C语言实现ipv4地址字符串是否合法
- MyBatis(3.2.3) - Configuring MyBatis using XML, typeHandlers
- 第十篇 一个利用反射实现的Excel导出
- java.sql.SQLException: Access denied for user 'sa'@'localhost' (using password: YES)
- R语言-用户细分
- VUE中 style scoped 修改原有样式
- Python:Day27 socketserver、线程
- idea快捷键列表
- Java编程的逻辑 (79) - 方便的CompletionService
热门文章
- 【Luogu】P4172水管局长(LCT)
- node.js express 4.x 安装指南(Express不是内部或外部命令解决方案)
- 服务器提交了协议冲突。Section=ResponseHeader Detail=标头名称无效
- spring+freemarker+redis
- vue2+nodejs+mongodb搭建移动端网站
- EclEmma Java Code Coverage for Eclipse
- Docker分层原理与内部结构
- 51Nod 1028 大数乘法 V2
- 为IIS添加json扩展类型文件的MiME类型
- javascript获取querystring值【个人觉得这种方法最好最棒最像.NET】