9

I'm trying to programmatically disable suggestions with setInputType() using InputType TYPE_TEXT_FLAG_NO_SUGGESTIONS.

While this works for most keyboards, this doesn't work when using the "Gboard" keyboard; even with this input type, suggestions always appear. The problem is that the user can choose if he wants to have suggestions on input fields, regardless of the input type specified by the EditText.

How can the suggestions be suppressed for all keyboards, including Gboard?

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
SuisJeux
  • 213
  • 2
  • 9

2 Answers2

5

I found a solution :

view.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

However you can see a little Font difference between an Input with suggestions and without.

SuisJeux
  • 213
  • 2
  • 9
-2
<EditText
                android:id="@+id/inputISD_Code"
                android:layout_width="0dip"
                android:layout_height="match_parent"
                android:layout_marginLeft="@dimen/dimen20"
                android:layout_weight="20"
                android:background="@null"
                android:fontFamily="sans-serif-light"
                android:hint="@string/code"
                android:inputType="text|textNoSuggestions"
                android:maxLength="10"
                android:textColor="@color/black"
                android:textCursorDrawable="@null"
                android:textSize="18dp" />
PRATEEK BHARDWAJ
  • 2,364
  • 2
  • 21
  • 35