Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 770
ErlVolton Avatar asked Aug 28 '14 15:08

ErlVolton


People also ask

How to not show keyboard on EditText Android?

editTextNum. setShowSoftInputOnFocus(false); to disable the software keyboard showing when the EditText is touched. the hideKeyboard(this); call in OnCreate to forcible hide the software keyboard.


3 Answers

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!

like image 139
sweggersen Avatar answered Sep 23 '22 17:09

sweggersen


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"
like image 22
Adam Hurwitz Avatar answered Sep 23 '22 17:09

Adam Hurwitz


Add android:inputType="textNoSuggestions" to editext

like image 23
Ajinkya Patil Avatar answered Sep 20 '22 17:09

Ajinkya Patil