I am playing with the two-way binding of the data binding API which was introduced in Android Studio 2.1 AFIK.
I get this interesting error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.RuntimeException: Found data binding errors.
****/ data binding error ****msg:The expression address.street cannot cannot be inverted: Two-way binding cannot resolve a setter for java.lang.String property 'street'
file:/path/to/layout.xml
loc:34:37 - 34:50 ****\ data binding error ****
When I try to google that error I just find a 4 day old Japanese Twitter posting from a guy who is crying about it...
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/edit_hint_zip"
android:text="@={address.zip}"
tools:text="12345"/>
That address.zip
is a String
. I am guessing that the problem here is CharSequence
vs. String
as the return value of EditText.getText()
.
My idea was to defining it however this does not work for me:
@NonNull
@InverseBindingAdapter(attribute = "text")
public static String getText(EditText edit) {
return edit.getText().toString();
}
What did I miss?