View 的構造方法的調用順序

view 構造方法的調用順序:

:boom:this

public View(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}

:boom:code

public View(Context context, AttributeSet attrs, int defStyleAttr) {
    this(context, attrs, defStyleAttr, 0);
}

:boom:get

public View(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    this(context);
     ...
}

:boom: ####最終都要調用 > View(Context context)方法

public View(Context context) {
    mContext = context;
    mResources = context != null ? context.getResources() : null;
    mViewFlags = SOUND_EFFECTS_ENABLED | HAPTIC_FEEDBACK_ENABLED;
    // Set some flags defaults
    mPrivateFlags2 =
            (LAYOUT_DIRECTI
    ...
}
相關文章
相關標籤/搜索