1
RxJava2を使用してユーザー名とパスワードが十分に長いのにログインボタンを有効にしたいがエラーが発生する。JDK8でAndroid上でRxJava2を使用してログインボタンを有効にする
そしてa && b
のエラーが
あり、他のエラーがあるが、私は考えている:あなたは、これは誤りであるmap(inputText
を参照してください両方のセクションのために
final Button loginButton = (Button) view.findViewById(R.id.loginbutton);
final TextView usernameField = (TextView) view.findViewById(R.id.username_logindialog);
Observable<Boolean> userNameValid = RxTextView.textChangeEvents(usernameField)
.map(e -> e.text())
.map(inputText -> inputText.length() > 4);
final TextView passwordField = (TextView) view.findViewById(R.id.password_logindialog);
Observable<Boolean> passwordValid = RxTextView.textChangeEvents(passwordField)
.map(e -> e.text())
.map(inputText -> inputText.length() > 7);
Observable<Boolean> registerEnabled =
Observable.combineLatest(userNameValid, passwordValid, (a,b) -> a && b);
registerEnabled.registerObserver(enabled -> loginButton.setEnabled(enabled));
最初の2つのエラーは根本的な原因ですが、私は私が何を参照していない今すぐObservable.combineLatest
の代わりにuldを使用してください。
ありがとう使用することができます。 rx.Observable.combineLatestを置くだけでコンパイルできます。 –