How to disable displaying "suggestions" on the Soft Keyboard

Android

Android Problem Overview


I want to turn off displaying "Suggested Words" on the soft/virtual keyboard when someone is using my application (only on certain Activities). For the default Android keyboard, this can be found under 'Settings' (under Word Suggestion Settings).

Is there a way to disable it only within your application, without requiring the user to manually go and do it? I basically want the user to type words without providing any hints.

Thanks!

Android Solutions


Solution 1 - Android

When developing for 2.0+, the supposed way is setting android:inputType="textNoSuggestions" (ref). Unfortunately, suggestions are still shown on HTC Desire 2.2 (and probably other HTC Sense devices as well).
Using android:inputType="textVisiblePassword"will not help as well as the software keyboard by HTC won't allow you to switch languages.
So I stick to android:inputType="textFilter" to disable suggestions.

Solution 2 - Android

You can disable suggestions on the Soft Keyboard by adding the following line in the xml -

android:inputType="textNoSuggestions"

However according to this article, it may or may not be supported by the IME (the keyboard).

If this issue occurs, the below method works for sure -

android:inputType="textNoSuggestions|textVisiblePassword"

Solution 3 - Android

This works for me with the stock keyboard, even on HTC with 2.2

final EditText et = (EditText) findViewById(R.id.SearchText);
et.setInputType(et.getInputType()
	| EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS
	| EditorInfo.TYPE_TEXT_VARIATION_FILTER);

Solution 4 - Android

On my 6P running Nougat, nothing worked. While it is empty the suggestion bar stays up because it has the microphone icon on the right side. In order to get rid of that, I used fingerup's suggestion in one of the comments and it worked! So I decided to write an actual answer so people don't miss it. To recap here's what I've used:

    android:inputType="textNoSuggestions|textFilter|textVisiblePassword"
    android:privateImeOptions="nm"

inputType="textNoSuggestions|textFilter|textVisiblePassword" prevents suggestions, and privateImeOptions="nm" (stands for "no microphone") prevents the bar from showing up because it still would since the mic button is in it. So it is necessary to use both attributes because if all you do is specify no mic then the bar still shows up with recommendations.
Thx again to fingerup for mentioning the nm trick. ;)

Solution 5 - Android

There are two ways that I know of to disable the auto-complete. One way is through the XML by setting the android:inputType="textVisiblePassword" in the layout xml.

The other way is through code such as the following

EdtiText editTextBox = findViewById(R.id.myEditTextView);
editTextBox.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);

Solution 6 - Android

I was facing the same issue on Samsung devices using:

android:inputType="textNoSuggestions|textFilter|textVisiblePassword"

   

only after setting the inputType to password and visiblePassword worked for me:

android:inputType="textPassword|textVisiblePassword"

Solution 7 - Android

android:inputType="textPhonetic" hides soft keyboard suggestions on Android 1.6.

Solution 8 - Android

hope this works for you,

editText.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_CAP_SENTENCES|InputType.TYPE_TEXT_FLAG_MULTI_LINE|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Solution 9 - Android

If you are using InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS in activity, it will work fine. In case of DialogFragment, you should place InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS at onActivityCreated() handler as below :-

@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		EditText editTextUsername =  (EditText)dialogView.findViewById(R.id.txtUsername);
		editTextUsername.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionThiraView Question on Stackoverflow
Solution 1 - AndroidyanchenkoView Answer on Stackoverflow
Solution 2 - AndroidAmeya PandilwarView Answer on Stackoverflow
Solution 3 - AndroidSoftWyerView Answer on Stackoverflow
Solution 4 - AndroidFrancois DermuView Answer on Stackoverflow
Solution 5 - AndroiddlongestView Answer on Stackoverflow
Solution 6 - AndroidOushView Answer on Stackoverflow
Solution 7 - AndroidbancerView Answer on Stackoverflow
Solution 8 - AndroidHarshal BenakeView Answer on Stackoverflow
Solution 9 - AndroidShalu T DView Answer on Stackoverflow