Trying to use DataBinding in a CustomView(Group)
layout looks like this:
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<merge
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/customview_checkbox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="@string/checkbox_value_key"
android:text="My CheckBox"/>
....
</merge>
</layout>
CustomView (extends FrameLayout) inflation:
view = DataBindingUtil.inflate((LayoutInflater) getContext().getSystemService(Context
.LAYOUT_INFLATER_SERVICE), R.layout.custom_view, this, true);
results in this error:
Error:(46, 61) error: cannot find symbol method getResources()
Generated Binding Class:
public ViewBodyPartsBinding(android.databinding.DataBindingComponent bindingComponent, View[] root) {
super(bindingComponent, root[0], 0);
final Object[] bindings = mapBindings(bindingComponent, root, 9, sIncludes, sViewsWithIds);
this.mboundView0 = (android.widget.ImageView) bindings[0];
this.mboundView0.setTag(null);
this.mboundView2 = (android.support.percent.PercentRelativeLayout) bindings[2];
this.mboundView2.setTag(null);
....
this.customviewCheckbox1 = (android.widget.CheckBox) bindings[1];
this.customviewCheckbox1.setTag(root.getResources().getString(<package>.R.string.checkbox_value_key));
....
setRootTag(root);
// listeners
invalidateAll();
}