如何禁用拼写检查 Android edittext
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21449505/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to disable spellcheck Android edittext
提问by Sandah Aung
I want to remove the underlines from texts inside edittext fields.
我想从 edittext 字段内的文本中删除下划线。
How can I do that?
我怎样才能做到这一点?
回答by Chintan Rathod
You can do it with following code. Just paste it in layout of EditText
.
您可以使用以下代码来完成。只需将其粘贴到EditText
.
android:inputType="textNoSuggestions"
回答by ShutterSoul
In order to get rid of spell checking you have to specify the EditText
's InputType in the XML as the following:
为了摆脱拼写检查,您必须EditText
在 XML 中指定的 InputType 如下:
android:inputType="textNoSuggestions"
However, if your EditText
is multiline and also you need to get rid of spell checking,then you have to specify the EditText's InputType in the XML as the following:
但是,如果您EditText
是多行并且还需要摆脱拼写检查,那么您必须在 XML 中指定 EditText 的 InputType 如下:
android:inputType="textMultiLine|textNoSuggestions"
回答by Artemiy
Minor addition to Chintan's answer - such (and other) combination is also allowed:android:inputType="textCapSentences|textNoSuggestions"
对 Chintan 的回答的小补充 - 也允许这种(和其他)组合:android:inputType="textCapSentences|textNoSuggestions"
回答by simekadam
Or if you want to just disable the red underline (and the autocorrect dialog), you can override the isSuggestionsEnabled()
method on TextView
.
或者,如果您只想禁用红色下划线(和自动更正对话框),您可以覆盖 上的isSuggestionsEnabled()
方法TextView
。
This will keep the keyboard autocomplete working.
这将保持键盘自动完成工作。
回答by Akhilesh V S
I just Added a line in for EditText
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
我刚刚为 EditText 添加了一行
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
and it worked fine for me.
对我来说效果很好。
回答by SKP
So I was not able to find out any direct way of doing it. So went ahead with below workaround:
所以我无法找到任何直接的方法。所以继续下面的解决方法:
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
As the input type becomes a visible password, even if the spell check is enabled from the device settings, the Red underline won't appear. :)
当输入类型成为可见密码时,即使在设备设置中启用了拼写检查,也不会出现红色下划线。:)