android - 为什么我不能在 Android Studio 中定义 type="LiveData<Int>"?
问题描述
代码A可以正常工作,我不知道为什么代码b不能工作,你能告诉我吗?
代码 A
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="androidx.lifecycle.LiveData" />
<variable
name="MyValue1"
type="LiveData<Integer>" />
</data>
...
代码 B
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="androidx.lifecycle.LiveData" />
<variable
name="MyValue2"
type="LiveData<Int>" />
</data>
...
解决方案
因为Int
不是 用于数据绑定的表达式语言的一部分
推荐阅读
- android - Android 中的 AWS IoT Policy 不适用于自定义主题
- python - 如何为张量流中的矩阵中的每个行向量构造成对差异的平方?
- android - 我正在尝试通过我的 android 应用程序从圆形立方体发送电子邮件,但它显示错误
- swift - 很快,为什么我不能在有初始化程序时实例化协议?
- javascript - html javascript node.children 似乎是一个指针
- typescript - 在 TypeScript 中覆盖全局 JavaScript 函数
- sql - 在触发器之前运行一次以插入多行 PL/SQL
- angular - PrimeNG - 表合并 2 列的东西
- reactjs - React-Native 要求访问照片/文件/媒体?(我将 redux-persist 与 AsyncStorage 一起使用?)
- r - 如何在R中转换数据表结构