android - 出现错误“与属性色调 (attr) 颜色不兼容”。在使用数据绑定时
问题描述
我正在尝试在运行时使用数据绑定在图像上设置色调颜色
<ImageView
android:id="@+id/txtAppointmentEnable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src='@{paymentMethod.getActiveStatus().equalsIgnoreCase("DISABLE") ? @drawable/ic_action_navigation_close : @drawable/ic_add_white_36dp}'
android:tint='@{paymentMethod.getActiveStatus().equalsIgnoreCase("DISABLE") ? @color/favourite_red : @color/green_light'/>
我收到错误
error: '@{paymentMethod.getActiveStatus().equalsIgnoreCase("DISABLE") ? @color/favourite_red : @color/green_light' is incompatible with attribute tint (attr) color.
这个问题的可能解决方案是什么。
解决方案
最后加上}。
<ImageView
android:id="@+id/txtAppointmentEnable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src='@{paymentMethod.getActiveStatus().equalsIgnoreCase(`DISABLE`) ? @drawable/ic_action_navigation_close : @drawable/ic_add_white_36dp}'
android:tint='@{paymentMethod.getActiveStatus().equalsIgnoreCase(`DISABLE`) ? @color/favourite_red : @color/green_light}'/>
推荐阅读
- android - 跟踪通过我的应用程序打开的时间和链接
- jmeter - Jmeter 在非 gui 模式下运行时显示双倍结果
- c - C中的段错误(相同的逻辑在另一个程序中工作)
- ios - Crashlytics 不显示崩溃报告
- ocl - Eclipse OCL google.inject 创建异常
- java - JBoss SSO 允许跨安全域登录
- swift - (Swift) 拖放 NSOutlineview 时出现奇怪的反馈
- r - ggplot2:通过循环输出多个图
- javascript - 在输入中设置值时无法将属性“值”设置为 null
- sass - 如何将带有线性渐变的背景图像 CSS 转换为 SASS?