Good day, I am practising my skills using layout, just learned data binding, and I want to know how I can use a variable like defaultName within a textview, so I am trying to do this:
android:text="@={`hi `+ myName.defaultName}"
I want the output to be:
hi Travis Scott
But instead I get a nasty error which is this:
cannot find symbol class ActivityMainBindingImpl
import com.example.nickname.databinding.ActivityMainBindingImpl;
[databinding] {"msg":"The expression \u0027(\"hi \") + (myNameDefaultName)\u0027 cannot be inverted, so it cannot be used in a two-way binding\n\nDetails: Two-way binding with string concatenation operator (+) only supports the empty string constant (`` or \"\")","file":"app\\src\\main\\res\\layout\\activity_main.xml","pos":[{"line0":27,"col0":25,"line1":27,"col1":49}]}
^
I researched the error, I didn't find the solution. I researched what alternatives people have used to this problem and I didn't find anything. The only thing I found was this "@={hi
+ myName.defaultName}" and that's it.
You are trying to two-way binding instead of one-way binding. Just remove "=" sign and change brackets
android:text='@{"hi" + item.title}'