视图绑定随v3.6发布。
文件:https://developer.android.com/topic/libraries/view-binding
我的问题是,如何将视图绑定与自定义视图一起使用。Google文档仅显示了用例显示的“活动”和片段。
我试过了,但是什么也没显示。
LayoutInflater inflater = LayoutInflater.from(getContext());
然后,我用了这个,但还是没有运气。
LayoutInflater inflater = (LayoutInflater)
getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
我猜想,也许我没有针对我的视图设置正确的布局填充器,但不确定。
只需告知根,以及是否要附加到根
init { // inflate binding and add as view
binding = ResultProfileBinding.inflate(LayoutInflater.from(context), this, true)
}