相关疑难解决方法(0)

android数据绑定使用"&&"逻辑运算符

我试图使用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; 实体名称必须紧跟实体引用中的"&".

安卓工作室中的红色高亮显示错误"未转义和未终止字符".

那我该怎么办?

编辑: 找到答案,这些角色需要转义:

'&' --> '&'

'<' --> '&lt;'

'>' --> '&gt;'
Run Code Online (Sandbox Code Playgroud)

android bindable android-databinding

109
推荐指数
4
解决办法
4万
查看次数

标签 统计

android ×1

android-databinding ×1

bindable ×1