ButterKnife绑定视图与继承问题

CRO*_*OSP 5 android dependency-injection view butterknife

我已经阅读了github上的一些问题,但仍未找到解决方案.

我的问题是我无法在继承的子活动中绑定视图 BaseActivty

我的代码 BaseActivity

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewGroup rootView = (ViewGroup) this.findViewById(android.R.id.content);
        View rootBaseView = getLayoutInflater().inflate(R.layout.activity_base, rootView, false);
        ButterKnife.bind(this, rootBaseView);
        ....
         int childLayoutID = getLayoutResId();
        if (childLayoutID != LayoutConstants.NULL_LAYOUT_ID) {
           View childRootView = getLayoutInflater().inflate(childLayoutID, mLinearLayoutFrameContainer, false);
           mLinearLayoutFrameContainer.addView(childRootView);
       }
        ....
        setContentView(rootBaseView);
Run Code Online (Sandbox Code Playgroud)

所以,我有抽象的方法

   public abstract
    @LayoutRes
    int getLayoutResId();
Run Code Online (Sandbox Code Playgroud)

在任何子活动中,我返回特定的布局资源.

BaseActivity正确注入所有视图,但在任何子活动视图中,即使使用@Nullable注释也无法注入视图,视图在运行时为null.

我怎么解决这个问题.也许有一些解决方法?

附加信息

我试过不同的方式

    ButterKnife.bind(this);
    ButterKnife.bind(this,mLinearLayoutFrameContainer);
Run Code Online (Sandbox Code Playgroud)

onCreate方法中的儿童活动.

但仍然是一样的

但对于片段我有相同的情况,它的工作原理.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    Log.e("FRAGMENT", "ON VIEW CREATED " + getClass().getCanonicalName());
Run Code Online (Sandbox Code Playgroud)

在任何子片段中,我根本不调用ButterKnife注入方法,只注释注释的字段,当然我只在调用onViewCreated后开始使用视图super.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setupViews();
Run Code Online (Sandbox Code Playgroud)