How can I use logical operations in data binding to android?

In my layout file, I am trying to use the following syntax to specify text inside a TextView :

 android:text="@{user.isMe() && user.status.isEmpty() ? @string/EmptyStatusHint : user.status}"/> 

and I get:

[Fatal Error] fragment_user_profile.xml: 142: 58: the object name should immediately follow the & symbol in the object link.

The Data Binding Guide is nothing special.

So, regarding this situation, I have two questions:

  • How can I use my boolean operator in xml to bind data?
  • What is the β€œobject” mentioned in the error report? I guess I should know that))
+5
source share
1 answer

You should write && as && .

+7
source

Source: https://habr.com/ru/post/1245854/


All Articles