ErlVolton
ErlVolton

Reputation: 6784

In Android EditText, how to remove suggestions bar from soft keyboard?

I have an android app with an EditText field in one of my layouts. I have set android:inputType="textNoSuggestions" attribute for my EditText. The text field no longer displays suggestions. However, the suggestions bar is still at the top of the soft keyboard and right now seems to only serve the purpose of displaying the voice input microphone icon. I don't want/care about voice input for this field either, and would like to remove the suggestions bar from this soft keyboard. Is there a way to do that, possibly with another inputType flag?

Upvotes: 21

Views: 7298

Answers (3)

AdamHurwitz
AdamHurwitz

Reputation: 10384

The combination of XML attributes that removed both the Suggestions and the Suggestions Bar while retaining multi-line text was the following:

android:privateImeOptions="nm"
android:inputType="textNoSuggestions | textMultiLine"

or

android:privateImeOptions="nm"
android:inputType="textFilter | textMultiLine"

Upvotes: 4

Ajinkya Patil
Ajinkya Patil

Reputation: 5548

Add android:inputType="textNoSuggestions" to editext

Upvotes: 1

sweggersen
sweggersen

Reputation: 2362

I've found a solution that works for me. Looking at the logcat while pressing the search bar in Google Now launcher shows the following:

07-03 19:50:07.760    1304-1304/? W/LatinIME﹕ Deprecated private IME option specified: nm
07-03 19:50:07.760    1304-1304/? W/LatinIME﹕ Use com.google.android.inputmethod.latin.noMicrophoneKey instead

So, what I did was adding this line in the EditText xml:

android:privateImeOptions="nm"

"nm" is taken from the source code of LatinIME: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/inputmethod/latin/LatinIME.java#93

public static final String IME_OPTION_NO_MICROPHONE_COMPAT = "nm";

Hope this helps!

Upvotes: 14

Related Questions