Home » Android » android – How can I turn off suggestions in EditText?

android – How can I turn off suggestions in EditText?

Posted by: admin April 23, 2020 Leave a comment

Questions:

How can I turn off suggestions in EditText in Android?

How to&Answers:

It’s already described in the link Yoni Samlan posted. You should read the documentation correctly 😉

There is a method called setInputType. All you need is to call it with

edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Answer:

android:inputType="textNoSuggestions"

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

However, this seems to work more often

android:inputType="textNoSuggestions|textVisiblePassword"

Answer:

This seems to work better;

edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);

i.e. the visible password and no suggestion input types are OR’d together

To make sure you can also add this attribute to your edit text

android:inputType="textNoSuggestions|textVisiblePassword"

Answer:

android:inputType="textNoSuggestions". See the xml attribute documentation and this Android developers blog post.

Answer:

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);
}

Answer:

use the next workaround – I noticed that when sending Email messages no suggestion appear-

android:inputType="textCapSentences|textNoSuggestions|textEmailAddress"

It is not 100% but it is working 🙂

Answer:

If Editext/TextInputEditText has more than 1 line
then add textMultiLine

 android:minLines="10"
 android:inputType="textNoSuggestions|textMultiLine|textVisiblePassword"