how to combine Architecture Components with data binding on android?

Viewed 5937

I have developed app base on android data binding library: https://developer.android.com/topic/libraries/data-binding/index.html

class SignInViewModel extends BaseObservable {

    @Bindable
    public String getLogin() {
        return login;
    }

    @Bindable
    public String getPassword() {
        return password;
    }
}

and now I want to use ViewModelProviders from new library: https://developer.android.com/topic/libraries/architecture/guide.html

SignInViewModel signInViewModel = ViewModelProviders.of(this).get(SignInViewModel.class);

How it combine? any idea? or should be combined these two libraries?

Edit

I change to:

class SignInViewModel extends ViewModel {
   public ObservableField<String> login = new ObservableField<>("");

    public ObservableField<String> password = new ObservableField<>("");
}

and now compiles, but question is: is it right way?

4 Answers
Related