0

I want to disable auto-correction and auto-complete (word suggestions from the keyboard) on my cellphone within an app I'm working on. It's a vocabulary trainer, so I want the User to type the input without using any tools. Is there a way to do this with Java? Some relevant code snippets:

The user-interaction:

    public void onClick(View view) {
        TextView textView = (TextView) getView().findViewById(R.id.textview);
        final String answer = textView.getText().toString();
        passData(answer);
    }

And the xml:

   <EditText
        android:id="@+id/textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@id/button_first"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:background="#CCCCCC"
        android:ems="10"
        android:inputType="textPersonName" >

        <requestFocus />
    </EditText>

P.S. I'm new to App Development, so you might see some flaws in my code above - in that case, please tell me!

T. Pieper
  • 36
  • 4

2 Answers2

1

Does it work if you add this to your EditText:

android:inputType="text|textNoSuggestions"

Instead of:

android:inputType="textPersonName"

So it becomes this:

<EditText
    android:id="@+id/textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toTopOf="@id/button_first"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:background="#CCCCCC"
    android:ems="10"
    android:inputType="text|textNoSuggestions" >

    <requestFocus />
</EditText>
  • Thanks, that tipped me off. For my case it doesn't work, but instead i can use: android:inputType="textVisiblePassword" – T. Pieper Apr 04 '20 at 17:38
1

Programatically

sampleEdt.inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS

Documentation

Can be combined with text and its variations to indicate that the IME should not show any dictionary-based word suggestions. Corresponds to InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS.

Arda Kazancı
  • 8,341
  • 4
  • 28
  • 50