Search code examples
androidandroid-databinding

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


The following code:

public ObservableField ofFoo = new ObservableField("");

Generates the following warning:

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

What is the right way to avoid this warning?


Solution

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

    Though I don't understand why you want to wrap an empty string as an observable.