How to write the equivalent expression of Ternary operation in android xml while using data binding.
android:visibility="@{(assessmentquestionanswer.type.equals(@string/editText_type)? View.VISIBLE : View.GONE) || (assessmentquestionanswer.type.equals(@string/date)? View.VISIBLE : View.GONE)}"
Currently I am getting an error message as must be able to find a common parent for boolean and int
Your way of implementation is wrong, your current condition is like
(assessmentquestionanswer.type.equals(@string/editText_type)? View.VISIBLE : View.GONE) || (assessmentquestionanswer.type.equals(@string/date)? View.VISIBLE : View.GONE)
View.VISIBLE || View.VISIBLE
which is not right. It should be
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}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.