Is there a way to programmatically turn off that autosuggest list which pops up as you type in EditText?
16 Answers
I had the same question but I still wanted to set this option in my XML file so I did a little more research until I found it out myself.
Add this line into your EditText.
android:inputType="textFilter"
Here is a Tip. Use this line if you want to be able to use the "enter" key.
android:inputType="textFilter|textMultiLine"

- 2,147
- 1
- 14
- 10
-
HAVE MY UPVOTE! Actually this works really well when you want to make an EditText look like a textView. – sir_k Feb 12 '15 at 19:55
-
1Doesn't work in a couple of Android 4.4 phones either – voghDev Sep 21 '17 at 12:28
-
1API 24/Android 7.0: I replaced `android:inputType="textPersonName"` with the suggested text but it still displays the suggestion row (with the mic icon). – Neph Feb 25 '20 at 14:35
-
I used in textinputlayout with edittext still show the frequently used email – mayur.pancholi May 28 '21 at 08:25
-
5
-
108
-
18
-
According to the documentation this should be the right to do this, but some keyboards ignore this option: http://support.swiftkey.net/forums/116693-2-bug-reports/suggestions/3684116-swiftkey-insist-on-making-prediction-even-for-edit – Luiz Aoqui Apr 15 '14 at 00:50
-
1Though you then lose the ENTER key. If you want to be able to use ENTERs android:inputType="textNoSuggestions|textMultiLine" – barlop Jul 28 '14 at 14:25
-
This seems to be ignored by samsung tab3s default keyboard as does filter – Daniel Jonker Oct 14 '14 at 20:45
-
3It disables suggestions but still shows suggestion row (have a mic option in it). – VipulKumar Jan 09 '15 at 06:11
-
-
-
Also ignored by the AS emulator w/ Pixel XL image, API level 24. The VISIBLE_PASSWORD work around works though. – CodeClown42 Jan 20 '21 at 23:03
-
android:inputType="textVisiblePassword"
works like a charm

- 2,474
- 2
- 35
- 53
-
3I would not go this route. It is a hack and you do not mention what other features of the keyboard may change when you tell it it is for password. Use "text|textNoSuggestions". – Michael Peterson Mar 04 '15 at 19:02
-
3@P1X3L5 textNoSuggestions does not work for many devices. Unfortunately this hack is necessary until Google fixes that – Tariq Jul 10 '15 at 23:26
-
1for me it was better, it also removes the strip above the keyboard (nexus 5) which doesn't have to be true for all devices but gives better performance for some users (it also turns off the ability for speech input) – Arkadiusz Cieśliński Nov 21 '15 at 09:45
-
1this worked to remove the `.` period char added at the end of the word if two spaces are typed after that word. I used it for the action bar searchView `((SearchView) MenuItemCompat.getActionView(searchItem)) .setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);` – Gene Bo Jun 27 '16 at 19:39
-
This is the only solution that worked for me. Other answers don't work when moving through a form and returning to a field. Google are such a bunch of dopes. Releasing such simple features that are incomplete and poorly tested. – angryITguy Aug 20 '18 at 00:20
-
Note that for accessibility purposes, this inputType now treats the edittext as a password and the talkback mode will announce "showing password keyboard" when the keyboard appears. This can add confusion to users that use TalkBack mode on your app. – h_k Nov 01 '19 at 18:58
-
1thanks @Mr_Hmp this works well. But there is a situation, I need first letter of each word to be capital. For this we have "textCapWords", but this does not work with "textVisiblePassword". Please advise – Parmendra Singh Mar 04 '20 at 06:51
-
If you need to capitalize first one you could do that on onTextChanged callback. this is the one that worked for my use case, no suggestions shows suggestions with the google keyboard. – Lassi Kinnunen Mar 05 '20 at 05:47
Ways to do it:
- Programatically
editText.inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
- XML
android:inputType="textNoSuggestions"
If you already have some flags set, then:
- Programatically
inputType = if (disableSuggestions) {
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS or inputType
} else {
inputType and InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS.inv()
}
- XML
android:inputType="textNoSuggestions|textPassword"
For the android version 8.0 or above this code is not working and for the autocomplete textview also this code not working so i will suggest you to use below code for the Disable the auto suggestions in 8.0 or above android vesrion use this property of edittext android:importantForAutofill="no"
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:focusable="false"
android:imeOptions="actionDone"
android:maxLength="80"
android:maxLines="1"
android:textColor="@color/colorBlack"
android:textColorHint="@color/colorBlack"
android:importantForAutofill="no"
android:textSize="@dimen/_12sdp"
app:bFontsEdt="light" />
and for the AutoComplete textview like this use this Field to Disable Auto suggestion android:importantForAutofill="no" :
<AutoCompleteTextView
android:id="@+id/autocompleteEditTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_3sdp"
android:layout_marginTop="@dimen/_5sdp"
android:background="@null"
android:imeOptions="actionDone"
android:singleLine="true"
android:text=""
android:textColor="@color/colorBlack"
android:textColorHint="@color/colorGrayDark"
android:importantForAutofill="no"
android:textSize="@dimen/_12sdp" />

- 1,349
- 12
- 19
-
2
-
The only thing that works for me, thx @MaheshKeshvala , upvoted for saving my day. – Ravi Vaniya Jan 24 '20 at 07:19
-
Auto-fill is not keyboard auto-complete, they are different features. Auto-fill is handled by the OS, whereas auto-complete is handled by the keyboard developer (hopefully). – milosmns Mar 04 '20 at 09:49
The most reliable approach I have found to getting rid of autocomplete is to use
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
on your EditText control. As charlie has reported in a different answer on this page,
android:inputType="textVisiblePassword"
is the XML version of this flag.
You can combine this flag with
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
I had been using InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS without InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, which worked for most phones, but then I came across a Samsung phone for which I was still getting autocomplete.
Android programmatically disable autocomplete/autosuggest for EditText in emulator
which suggested using InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD.
I tried this (along with InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) and it worked. You can see why even a phone that might not take the hint that you don't want autocomplete would have to allow it to be disabled for a password field. Short of holding our breath, this might be the best way to get what we want from such phones.
On some of my devices, the font was slightly changed by this flag - most noticeably to distinguish a zero (0) from an Oh (O) more clearly, which obviously would be important for displaying a password. But at least it worked, and the new font was not unattractive.
Even though the post on which I found this suggestion was old, the phone I tested on was very recent - a Samsung Galaxy Note II (SPH-L900) stock Android 4.1.2 from Sprint. The keyboard selected was "Samsung Keyboard," and apparently this was the default for this phone when the customer received it from Sprint. So this problem apparently has persisted over the years for at least some of the important Samsung line of phones.
For those of you who, like me, do not have a Samsung test device, this could be important information.
-
3
-
@SargeBorsch: Are you saying that TYPE_TEXT_VARIATION_VISIBLE_PASSWORD along with TYPE_TEXT_FLAG_NO_SUGGESTIONS still performs an auto-complete on your S3? I so, are you using the stock keyboard? I don't have an S3 but have tried my app (which uses the above approach) on an S3 in the past and there was no auto-complete. I have an S4 running Android 4.4 (Cyanogenmod) and it also does not auto-complete. – Carl Nov 18 '14 at 20:45
-
@SargeBorsch: If you would like to try an app that uses the above approach on your S3, here is mine: https://play.google.com/store/apps/details?id=com.goalstate.WordGames.FullBoard.trialsuite Would be interested to hear whether the Check Word field at the bottom of that app (which uses the above flags) tries to auto-complete on your device. TIA. – Carl Nov 18 '14 at 20:46
-
-
>"Are you saying that TYPE_TEXT_VARIATION_VISIBLE_PASSWORD along with TYPE_TEXT_FLAG_NO_SUGGESTIONS still performs an auto-complete on your S3?" Yes, exactly. Although there's also E-mail type, because it's an email input… – Display Name Nov 19 '14 at 08:46
-
No, Check Word field doesn't invoke autocompletion. seems like E-mail flag causes the problem. – Display Name Nov 19 '14 at 08:50
-
Ah. So it is still a solution with just the two flags listed, then. Thanks for checking. – Carl Nov 19 '14 at 12:57
-
*"I came across a Samsung phone for which I was still getting autocomplete"* -> Hey, 7 years later and TYPE_TEXT_FLAG_NO_SUGGESTIONS has absolutely no effect in **the AS emulator running a Google Pixel image**. >_< But VISIBLE_PASSWORD works. Thanks much. – CodeClown42 Jan 20 '21 at 23:00
This worked for me
android:importantForAutofill="no"
android:inputType="none|textNoSuggestions"

- 6,198
- 2
- 47
- 58
I was getting this thing on samsung phones running 4.4.4. This solved my problem
android:inputType="text|textVisiblePassword|textNoSuggestions"

- 3,068
- 2
- 30
- 31
-
Same on Samsung running 8.1. Only thing that worked for me was android:inputType="textVisiblePassword|textNoSuggestions" – Eino Gourdin Mar 06 '20 at 11:23
As this is still an issue, I'm going to post this answer. android:inputType="textVisiblePassword" works but it is undesirable, first because it's a misrepresentation of the input and second because it disables Gesture Typing!
Instead I had to use BOTH flags textNoSuggestions and textFilter. Either one alone did not work.
android:inputType="textCapSentences|textFilter|textNoSuggestions"
The textCapSentences was for other reasons. But this inputType kept the swipe typing and disabled the suggestion toolbar.

- 593
- 2
- 7
- 21
OK, the problem was - in Eclipse you don't get suggestion for flag named: textNoSuggestion
And you can't set it in main.xml (where you design UI) because that attribute for inputType isn't recognized. So you can set it in code using int const:
EditText txtTypeIt = (EditText) this.findViewById(R.id.txtTypeIt);
txtTypeIt.setInputType(524288);
And thanks jasta00 for helping me out figure answer for this one.

- 54,010
- 13
- 102
- 111

- 20,366
- 24
- 120
- 181
-
6This does the job... .setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); – w.donahue Aug 03 '11 at 18:51
-
2
-
1@kape123 You can't set android:inputType="textNoSuggestions" in xml because your build target is lower than 5 api – k4dima Mar 04 '12 at 14:14
-
Note that for some Samsung phones the standard keyboard autocomplete does not get turned off by InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS. One person suggests using InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD in this rather old post: http://stackoverflow.com/questions/6281514/android-programmatically-disable-autocomplete-autosuggest-for-edittext-in-emulat – Carl Jun 03 '13 at 17:30
// 100% correct & tested
txtKey = (EditText) view.findViewById(R.id.txtKey);
txtKey.setPrivateImeOptions("nm");
txtKey.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
txtKey.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
}

- 91
- 4
EditText emailTxt=(EditText)findViewById(R.id.email);
emailTxt.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
This will help you.

- 658
- 8
- 7
You could simply use the EditText's setThreshold()
method. Set the threshold to let's say 100 when you don't want to show predictions. If you want to re-activate showing predictions, set it back to a small int like 1 or 2 depending on your needs.

- 4,817
- 5
- 42
- 53
if you don't want suggestion you can use "none"
android:inputType="none|numberDecimal"

- 125
- 2
- 4
Find a good solution for auto suggestions with TextWatcher. The suggestions will appear for user, but user will not be able accept them.
/*...*/
editText.addTextChangedListener(textWatcher);
/*...*/
}
private final TextWatcher textWatcher = new TextWatcher() {
long timestamp = 0L;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!longClickable && count - before > 1 && timestamp < System.currentTimeMillis()) { // disable suggestions click
String str = s.toString();
str = str.substring(0, before);
timestamp = System.currentTimeMillis() + 20;
inputText.setText(str);
inputText.setSelection(inputText.getText().length());
}
}
@Override
public void afterTextChanged(Editable s) {
}
};
Also this works good when you don't need a long click with copy/paste functionality

- 1,505
- 16
- 14