在我的布局文件中,我尝试使用以下语法来指定 TextView
中的文本:
android:text="@{user.isMe() && user.status.isEmpty() ? @string/EmptyStatusHint : user.status}"/>
我得到:
[Fatal Error] fragment_user_profile.xml:142:58: The entity name must immediately follow the '&' in the entity reference.
在Data Binding Guide没有什么特别之处。
所以,对于这种情况,我有两个问题:
- 如何使用 xml 中的逻辑语句进行数据绑定(bind)?
- 错误报告中提到的“实体”是什么?我想我应该知道 ))
最佳答案
您必须将 && 写为 &&
。
关于android - 如何在 android 数据绑定(bind)中使用逻辑操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36247529/