欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

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}"