我正尝试在使用Android DataBinding时,在xml中使用"&&"运算符,
android:visibility="@{(bean.currentSpaceId == bean.selectedSpaceId && bean.currentSpaceId > 0)? View.VISIBLE: View.GONE}"
但是我得到了编译错误:
Error:Execution failed for task ':app:dataBindingProcessLayoutsDevDebug'. org.xml.sax.SAXParseException; systemId: file:/Users/path/app/build/intermediates/res/merged/dev/debug/layout/fragment_space.xml; lineNumber: 106; columnNumber: 89; The entity name must immediately follow the '&' in the entity reference.
并且在Android Studio中以红色突出显示"unescaped & or non terminated character"。
那么我应该如何解决这个问题?
编辑: 找到了答案,这些字符需要转义:
'&' --> '&'
'<' --> '<'
'>' --> '>'