setContentView的源码

来源:互联网 发布:知行理工登录不上 编辑:程序博客网 时间:2024/06/07 18:49
今天突然想看下函数setContentView的源码,谁知竟然这么难找。 当调用该函数时,调用的顺序大概为:Activity.setContentView()-->Window.setContentView()-->MidWindow.setContentView()其中MidWindow继承了类Window,实现了函数setContentView,具体的源码如下: public voidsetContentView(int layoutResID) { if (mContentParent == null) {installDecor(); } else { mContentParent.removeAllViews(); }mLayoutInflater.inflate(layoutResID, mContentParent); finalCallback cb = getCallback(); if (cb != null) {cb.onContentChanged(); } }要找到函数源码关键在于找到类MidWindow,要想找到MidWindow可先找到类com.android.internal.policy.impl.Policy。我在自己下载的源码中是找不到这个类的,不知道为什么。后来在开源中国社区中找到了。地址:http://www.oschina.net/code/explore/android-2.2-froyo/com/android/internal/policy/impl/Policy.javaMidWindow类的地址:http://www.oschina.net/code/explore/android-2.2-froyo/com/android/internal/policy/impl/MidWindow.java
原创粉丝点击