我已经基于Android Data Binding库开发了应用程序: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;
}
}
现在我想要使用来自新库的ViewModelProviders: https://developer.android.com/topic/libraries/architecture/guide.html
SignInViewModel signInViewModel = ViewModelProviders.of(this).get(SignInViewModel.class);
如何将它们结合起来?有什么想法吗?还是应该将这两个库结合起来?
编辑
我改为:
class SignInViewModel extends ViewModel {
public ObservableField<String> login = new ObservableField<>("");
public ObservableField<String> password = new ObservableField<>("");
}
现在编译通过了,但问题是:这是正确的方式吗?