android-有没有办法将绑定附加到setContentView活动
作者:互联网
目前,如果我要附加绑定,我可以
DataBindingUtil.setContentView(this, R.layout.main_activity);
我遇到了需要致电的自定义第三方活动的问题
setContentView(R.layout.main_activity);
如何将绑定附加到使用setContentView设置布局的活动
解决方法:
您需要先为布局充气,调用setContentView(inflatedView)并设置DataBinding:
/* I don't know if passing 'null' as parent breaks something in your layout, I tested it in
mine and it did work.*/
View rootView = LayoutInflater.from(this).inflate(R.layout.activity_main, null);
setContentView(rootView);
ActivityMainBinding binding = DataBindingUtil.bind(rootView);
标签:android-databinding,android 来源: https://codeday.me/bug/20191027/1941756.html