我在活动中具有一个自定义适配器类的gridView,我无法弄清楚如何将视图模型绑定到活动的gridView。
将<layout></layout>
放入行文件中,然后可以设置ViewModel
名称的变量名。现在,您可以在适配器的getViewHolder
中设置视图的膨胀,如下所示。
mTaskCustomLayoutBinding =
DataBindingUtil.inflate(inflater, R.layout.task_custom_layout, parent, false)
return MyViewHolder(this!!.mTaskCustomLayoutBinding!!)