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等。

最新文章

  1. RadioButton与CheckBox
  2. 《转载》使用org.w3c.dom.Element的setTextContent()、getTextContent()方法时出现编译错误
  3. 阅读ArrayBlockingQueue源码了解如何利用锁实现BlockingQueue
  4. android SDK下载及中文API地址
  5. Java期末设计(十三周)
  6. fontsize可以解决img标签插入图片之间的缝隙
  7. java.util.Properties
  8. SSRS2:Reporting Service 配置Service Account
  9. ubuntu下搭建lamp
  10. 动手学习TCP:4种定时器
  11. 蒙特卡洛法计算定积分—Importance Sampling
  12. 用C语言实现ipv4地址字符串是否合法
  13. MyBatis(3.2.3) - Configuring MyBatis using XML, typeHandlers
  14. 第十篇 一个利用反射实现的Excel导出
  15. java.sql.SQLException: Access denied for user 'sa'@'localhost' (using password: YES)
  16. R语言-用户细分
  17. VUE中 style scoped 修改原有样式
  18. Python:Day27 socketserver、线程
  19. idea快捷键列表
  20. Java编程的逻辑 (79) - 方便的CompletionService

热门文章

  1. 【Luogu】P4172水管局长(LCT)
  2. node.js express 4.x 安装指南(Express不是内部或外部命令解决方案)
  3. 服务器提交了协议冲突。Section=ResponseHeader Detail=标头名称无效
  4. spring+freemarker+redis
  5. vue2+nodejs+mongodb搭建移动端网站
  6. EclEmma Java Code Coverage for Eclipse
  7. Docker分层原理与内部结构
  8. 51Nod 1028 大数乘法 V2
  9. 为IIS添加json扩展类型文件的MiME类型
  10. javascript获取querystring值【个人觉得这种方法最好最棒最像.NET】