2

不工作的库模块的 BaseView:

@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Normal method to inflate the layout
        setContentView(R.layout.base_view_stub_layout);

        viewStub.setLayoutResource(getLayoutId());

        if (!hasStubInflated) {
            View inflatedView = viewStub.inflate();
            //Abstract method to bind inflatedView
            onViewStubInflated(inflatedView, savedInstanceState);
            //Normal method to hide progress bar 
            onViewStubInflated();
        }
    }

在没有viewStub的情况下工作的库模块的BaseView :

 @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Normal method to inflate the layout
        setContentView(getLayoutId());
     }

每个子视图都将覆盖的抽象方法:

public abstract int getLayoutId();

为什么在没有viewStub工作但不使用viewStub的情况下膨胀动态布局?

4

0 回答 0