Take the Dialog
for example.
Judge from the Android source code, let’s watch what happened when you called method Dialog#show()
method. The code can be simplified as below:
public void show() {
if (mShowing) {
// ...
return;
}
// ...
mDecor = mWindow.getDecorView();
mWindowManager.addView(mDecor, l);
// ...
mShowing = true;
// ...
}
The mDecor
field was got from mWidnow
, the mWindow
field was got from Dialog
's construcor:
Dialog(@NonNull Context context, @