[英]How to write Ternary operation condition in android XML while data binding
如何在使用数据绑定时在android xml中编写Ternary操作的等效表达式。
android:visibility="@{(assessmentquestionanswer.type.equals(@string/editText_type)? View.VISIBLE : View.GONE) || (assessmentquestionanswer.type.equals(@string/date)? View.VISIBLE : View.GONE)}"
目前我收到一条错误消息,因为必须能够找到boolean和int的公共父级
你的实施方式是错误的,你现在的状况是这样的
(assessmentquestionanswer.type.equals(@string/editText_type)? View.VISIBLE : View.GONE) || (assessmentquestionanswer.type.equals(@string/date)? View.VISIBLE : View.GONE)
View.VISIBLE || View.VISIBLE
这是不对的。 它应该是
android:visibility="@{(assessmentquestionanswer.type.equals(@string/editText_type) || assessmentquestionanswer.type.equals(@string/date)) ? View.VISIBLE : View.GONE}"
试试这样:
android:visibility="@{(assessmentquestionanswer.type.equals(@string/editText_type) || assessmentquestionanswer.type.equals(@string/date))? View.VISIBLE : View.GONE}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.