This is my thrid blog web site.

0%

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()