1. Activity的setContentView(int)方法,其实是这样的:


publicvoid1x1.gifsetContentView(intlayoutResID) {


getWindow().setContentView(layoutResID);

initActionBar();
}


getWindow()方法是返回自PolicyManager.makeNewWindow()方法


“mWindow = PolicyManager.makeNewWindow(this)”


这样获取的一个Window对象,由于Window是个抽象类,唯一的基础是PhoneWindow,所以查找到PhoneWindow的setContentView(int)方法:

publicvoid1x1.gifsetContentView(intlayoutResID) {
if ( mContentParent == null) {
installDecor();
} else {
mContentParent. removeAllViews();
}
1x1.gif
mLayoutInflater.inflate(layoutResID, mContentParent);
final Callback cb = getCallback();
if ( cb != null && ! isDestroyed()) {
cb. onContentChanged();
}
}


所以最后Activity中还是调用了LayoutInflater.inflate()方法。

更多相关文章

  1. Android NDK: Aborting出现NDK_PROJECT_PATH=null解决方法
  2. Android中用Toast.cancel()方法优化toast内容的显示
  3. 【从头学android】第二个程序同一个Activity中,切换布局时监听器
  4. JS或TS调用原生Android的方法
  5. 安装Android studio出现'tools.jar' seems to be not in Android
  6. Android 屏幕旋转后防止重新执行onCreate的方法。
  7. 【Android】‘activity supporting action_view is not set as b
  8. Android中完全退出程序的四种方法

随机推荐

  1. Mysql 5.7.18安装方法及启动MySQL服务的
  2. windows下mysql数据库主从配置教程
  3. MySQL 5.7忘记root密码后修改的详细教程
  4. MySQL execute、executeUpdate、executeQ
  5. MySQL绿色版设置编码以及1067错误详解
  6. Linux下MySQL5.7.18二进制包安装教程(无默
  7. Mysql 服务 1067 错误 的解决方法:修改my
  8. Mysql 5.7.18 解压版下载安装及启动mysql
  9. 解决Win7 x64安装解压版mysql 5.7.18 win
  10. Linux/Mac MySQL忘记密码命令行修改密码的