我试图使用Android数据绑定在xml中使用和"&&"运算符,
android:visibility="@{(bean.currentSpaceId == bean.selectedSpaceId **&&** bean.currentSpaceId > 0)? View.VISIBLE: View.GONE}"
但我得到了编译错误:
错误:任务':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; 实体名称必须紧跟实体引用中的"&".
安卓工作室中的红色高亮显示错误"未转义和未终止字符".
那我该怎么办?
编辑: 找到答案,这些角色需要转义:
'&' --> '&'
'<' --> '<'
'>' --> '>'
Run Code Online (Sandbox Code Playgroud)