本文介绍了数据绑定中的开关盒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有3个条件,如
value == 1然后打印A
值== 2然后打印B
值== 3然后打印C
有没有办法使用数据绑定在xml中做这些东西?
我知道我们可以实现条件语句,如
android:visibility =@ {age< 13?View.GONE:View.VISIBLE}
但是我在搜索switch case语句。
解决方案
不,据我所知,这是不可能的,也会使xml文件真的不可读。我认为最好在业务逻辑中实现,而不是布局文件。
Is it possible to write switch case with android Data Binding?
Suppose i have 3 conditions like
value == 1 then print A
value == 2 then print B
value == 3 then print C
Does there any way to do this stuff in xml by using Data Binding?
I know we can implement conditional statement like
android:visibility="@{age < 13 ? View.GONE : View.VISIBLE}"
But here i am searching for switch case statement.
解决方案
No, as far as I know it is not possible and also would make the xml files really unreadable. I think it would be better to implement this in your business logic, not in layout files.
这篇关于数据绑定中的开关盒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!