
<include androID:visibility="@{viewmodel.expandable ? VIEw.VISIBLE : VIEw.GONE}" bind:viewmodel="@{viewmodel}" layout="@layout/full_station_layout"/> 它运行良好,但我有一个问题:当recyclervIEw初始化并将项绑定到视图时,此布局在屏幕上闪烁一次,尽管初始值viewmodel.expandable为false.所以,我决定暂时隐藏这个布局并尝试在xml中使用default-parameter,如下所示:
<include androID:visibility="@{viewmodel.expandable ? VIEw.VISIBLE : VIEw.GONE,default=VIEw.GONE}" bind:viewmodel="@{viewmodel}" layout="@layout/full_station_layout"/> 但出了点问题:
error: 'VIEw' is incompatible with attribute androID:visibility (attr) enum [gone=2,invisible=1,visible=0].
所以,或者我错误地使用了这个参数或Google从xml数据绑定规则中删除了这个关键字(我之前在Google开发人员身上看过xml中使用default-keyword的例子,但现在我不能)
解决方法 您可以在默认属性中设置已消失,可见,不可见.替换为下面.<include androID:visibility="@{viewmodel.expandable ? VIEw.VISIBLE : VIEw.GONE,default=gone}" bind:viewmodel="@{viewmodel}" layout="@layout/full_station_layout"/> 总结 以上是内存溢出为你收集整理的Android数据绑定:在xml中设置默认可见性全部内容,希望文章能够帮你解决Android数据绑定:在xml中设置默认可见性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)