Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use logical operations in android data binding?

In my layout file I'm trying to use the following syntax to specify the text inside TextView:

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

and I'm getting:

[Fatal Error] fragment_user_profile.xml:142:58: The entity name must immediately follow the '&' in the entity reference.

In Data Binding Guide there is no something special about.

So, regarding this situatuion, I have two questions:

  1. How can I use my logical statement in xml for data binding?
  2. What is the "entity" mentioned in the error report? I suppose I should know that ))
like image 658
Alexey Avatar asked Mar 27 '16 12:03

Alexey


People also ask

What is difference between databinding and Viewbinding in Android?

View binding and data binding both generate binding classes that you can use to reference views directly. However, view binding is intended to handle simpler use cases and provides the following benefits over data binding: Faster compilation: View binding requires no annotation processing, so compile times are faster.

What is data binding in Android example?

In Android, the Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically.


1 Answers

You must write && as && .

like image 155
user2183539 Avatar answered Sep 22 '22 04:09

user2183539