android databinding的使用技巧
程序员文章站
2022-06-24 15:48:30
常用的使用方式就不说了 说说VIEW的隐藏与显示 1. 多状态使用,判断数字状态 android:visibility="@{(wrokItemBinding.itemType ......
常用的使用方式就不说了
说说view的隐藏与显示
1. 多状态使用,判断数字状态
<data>
<variable
name="wrokitembinding"
type="xxxx" />
</data>
android:visibility="@{(wrokitembinding.itemtype == 1)?view.visible:view.gone}"
2.判断是不是空 textutils 空就不显示
<data>
<import type="android.text.textutils" />
<import type="android.view.view" />
<variable
name="wrokitembinding"
type="xxxx" />
</data>
android:text="@{wrokitembinding.pointexectime,default=dd}"
android:visibility="@{textutils.isempty(wrokitembinding.pointexectime)?view.invisible:view.visible}"
上一篇: 白鼻子黑猫
下一篇: 使用栅格系统开发响应式页面