You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
I tried to use com.github.angads25.toggle.widget.LabeledSwitch with the Data Binding Library and I got the following error in the build:
android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:Could not find event 'android:onAttrChanged' on View type 'com.github.angads25.toggle.widget.LabeledSwitch'
What I have tried is:
<com.github.angads25.toggle.widget.LabeledSwitch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:textOn="Yes"
app:textOff="No"
android:checked="@={isChecked}"/>
and my binding adapters look like this:
@BindingAdapter("android:checked") // or "on"
public static void setChecked(LabeledSwitch view, Boolean isChecked) {
boolean blnValue = isChecked == null ? false : isChecked;
view.setOn(blnValue);
}
@InverseBindingAdapter(attribute = "android:checked") // or "on"
public static Boolean isChecked(LabeledSwitch view) {
return view.isOn();
}
What I had to do is 1) inherit from LabeledSwitch ; and 2) create this empty method:
public void onAttrChanged(final InverseBindingListener attrChange) { }
Setting a listener in the method resulted in the behaviour that the switch was changed its value twice (e.g. false -> true -> false). Example: setOnClickListener(v -> setOn(!isOn));
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I tried to use com.github.angads25.toggle.widget.LabeledSwitch with the Data Binding Library and I got the following error in the build:
android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:Could not find event 'android:onAttrChanged' on View type 'com.github.angads25.toggle.widget.LabeledSwitch'
What I have tried is:
<com.github.angads25.toggle.widget.LabeledSwitch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:textOn="Yes"
app:textOff="No"
android:checked="@={isChecked}"/>
or
<com.github.angads25.toggle.widget.LabeledSwitch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:textOn="Yes"
app:textOff="No"
app:on="@={isChecked}"/>
and my binding adapters look like this:
@BindingAdapter("android:checked") // or "on"
public static void setChecked(LabeledSwitch view, Boolean isChecked) {
boolean blnValue = isChecked == null ? false : isChecked;
view.setOn(blnValue);
}
@InverseBindingAdapter(attribute = "android:checked") // or "on"
public static Boolean isChecked(LabeledSwitch view) {
return view.isOn();
}
What I had to do is 1) inherit from LabeledSwitch ; and 2) create this empty method:
public void onAttrChanged(final InverseBindingListener attrChange) { }
Setting a listener in the method resulted in the behaviour that the switch was changed its value twice (e.g. false -> true -> false). Example: setOnClickListener(v -> setOn(!isOn));
The text was updated successfully, but these errors were encountered: