Android AppCompatActivity

Android AppCompatActivity

关系

  • extends FragmentActivity
  • implements AppCompatCallback, SupportParentable, DelegateProvider

与Activity 比较

setContentView

AppCompatActivity的setContentView ,调用this.getDelegate().setContentView(…)
而Acitivity的setContentView调用this.getWindow().setContentView(…)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// AppCompatActivity
public void setContentView(View view, LayoutParams params) {
this.getDelegate().setContentView(view, params);
}

public void setContentView(@LayoutRes int layoutResID) {
this.getDelegate().setContentView(layoutResID);
}

// Activity
public void setContentView(@LayoutRes int layoutResID) {
getWindow().setContentView(layoutResID);
initWindowDecorActionBar();
}

AppCompatActivity的setContentView调用的时候会调用一个this.getDelegate()

  • 版权声明: 本博客所有文章除特别声明外,均采用 Apache License 2.0 许可协议。转载请注明出处!
  • © 2020 Kfdykme
  • Powered by Hexo Theme Ayer
  • PV: UV:

请我喝杯咖啡吧~

支付宝
微信