Android Databinding in Sub-module

邮差的信 提交于 2019-12-03 08:40:08

Not sure if the issue is relevant to you but I managed to find some kind of the solution.

To make it work base class should have generic

class A<BINDING extends ViewDataBinding> {
    protected ABinding binding;

    void init(){
        binding = (ABinding) DataBindingUtil.setContentView(this, R.layout.a);
    }
}

and pass the same binding to the child class from the submodule

class B<ABinding> {
    // you can use instance in this class
}

The main problem here that you can't drastically change the UI, only hiding existing elements or add new at runtime. But I suppose in such case easier create a totally new class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!