android - 如何处理警告:Unchecked call to 'ObservableField(T)' as a member of raw type 'android.databinding.ObservableField'

标签 android android-databinding

以下代码:

public ObservableField ofFoo = new ObservableField("");

生成以下警告:

Unchecked call to 'ObservableField(T)' as a member of raw type 'android.databinding.ObservableField'

避免此警告的正确方法是什么?

最佳答案

ObservableField<String> ofFoo = new ObservableField<>("");

虽然我不明白为什么要将一个空字符串包装为一个可观察对象。

关于android - 如何处理警告:Unchecked call to 'ObservableField(T)' as a member of raw type 'android.databinding.ObservableField' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52467844/

相关文章:

android - 从新线程更新 TextView

android :background attribute using string color code 上的 android 数据绑定(bind)

android - 无法解决 MainActivityBinding 以及绑定(bind)相关问题

android - 如何通过 android 中的数据绑定(bind)将 onTextChanged 监听器添加到包含布局 xml

android - 快速滚动 recyclerView 列表时,RecyclerView 内的 NetworkImageView 有时不会加载图像。 Volley 网络响应缓慢

android - 无法使用react-native-navigation构建react-native

android - 当 Android 应用程序恢复时,全局变量的值是否会被重置?

android - 如何从应用程序模块调用库模块的 Activity

java - 使用绑定(bind)类的 inflate() 时,Android 数据绑定(bind)不起作用

android - 如何为 android :layout_marginLeft based LiveData<Boolean> in Android Studio? 绑定(bind)不同的值