4

I'm using TextInputEditText with databinding - it was running fine until recently. Here's one of the layouts that got this problem:

            <android.support.design.widget.TextInputLayout
                android:id="@+id/new_pass_confirm"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:hint="@string/new_pass_confirm_hint"
                app:errorEnabled="true"
                app:passwordToggleEnabled="true">

                <android.support.design.widget.TextInputEditText
                    android:id="@+id/new_pass_confirm_et"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:enabled="@{viewmodel.enabled &amp;&amp; !viewmodel.progress}"
                    android:imeOptions="actionDone"
                    android:inputType="textPassword"
                    android:maxLines="1"
                    android:text="@={viewmodel.newPassConfirm}"
                    android:textSize="18sp" />

            </android.support.design.widget.TextInputLayout>

But now whenever user tries to enter anything, app freezes and logcat gets flooded with repeated messages over and over:

V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@ccaf106 nm : package.my ic=com.android.internal.widget.EditableInputConnection@87ca3c7
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@e26ddb nm : package.my ic=com.android.internal.widget.EditableInputConnection@43b078
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@4fff78e nm : package.my ic=com.android.internal.widget.EditableInputConnection@43ddbaf
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
W/IInputConnectionWrapper: getCursorCapsMode on inactive InputConnection

The problem dissapears if I remove android:text="@={viewmodel.newPassConfirm}" Looks like the problem is with val newPassConfirm = ObservableField("") trying to change xml-field in an endless loop

It worked fine until few days ago What I've tried:

  • removing android:imeOptions="actionDone"

  • removing android:inputType="textPassword"

  • removed each of the below from the view layer:

    binding.newPassConfirm.setOnClickListener(v -> binding.newPassConfirm.setError(null));
    
    binding.newPassConfirmEt.addTextChangedListener(new DefaultTextWatcher() {
            @Override
            public void afterTextChanged(Editable s) {
                binding.newPassConfirm.setError(null);
            }
        });
    
    binding.newPassConfirmEt.setOnEditorActionListener(
                    (v, actionId, event) -> {
                        if (actionId == EditorInfo.IME_ACTION_DONE
                                || event.getAction() == KeyEvent.ACTION_DOWN
                                && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                            mViewModel.onOkClick();
                            return true;
                        }
                        return false;
                    });
    
Milad Bahmanabadi
  • 946
  • 11
  • 27
ildar ishalin
  • 685
  • 1
  • 9
  • 19
  • I am experiencing this same behaviour in Jetpack Compose TextField for Android version 9. How can this be resolved in Compose? #jetpack-compose – SabetiG Mar 14 '23 at 10:59

2 Answers2

0

The reason of error was this method in DataBindingAdapter

@BindingAdapter("android:text")
public static void setText(TextView textView, String text) {
    textView.setText(text != null ? text : "");
}

It might loop itself with databinding code, resulting with massive lags

ildar ishalin
  • 685
  • 1
  • 9
  • 19
0

Adding inputType="textPhonetic" in XML solved my problem:

android:inputType="textPhonetic"

Not sure which input type causes this lag. Wasted my day on this!