Hen*_*son 43 android spell-checking word-wrap android-edittext android-4.0-ice-cream-sandwich
在运行Android 4.0(Ice Cream Sandwich)的Android模拟器上测试时,我注意到Edittext做了一些非常奇怪的事情.
首先,它强调了用红色标识为"拼写错误"的每个单词.如何禁用此功能?其次,尽管在布局XML中我指定了android:scrollHorizontally="true"自动换行:如何禁用它?以下是Edittext的Layout XML代码:
<EditText
android:id="@+id/editor"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_below="@+id/toolbar"
android:layout_toRightOf="@+id/toolbarleft"
android:paddingBottom="0dp"
android:paddingRight="0dp"
android:scrollHorizontally="true"
android:text=""
android:inputType="textMultiLine" >
<requestFocus />
</Edittext>
Run Code Online (Sandbox Code Playgroud)
以下是我需要禁用的拼写检查器的示例:
拼写检查器的演示http://www.abstract-thoughts.com/wp-content/uploads/2011/10/spell.jpg
非常感谢!
Hen*_*son 87
禁用拼写检查
为了摆脱拼写检查,您必须在XML中指定EditText的InputType,如下所示:
android:inputType="textNoSuggestions"
但是,我的EditText也需要是多行的,所以我在EditText的XML中添加了以下行:
android:inputType="textMultiLine|textNoSuggestions"
禁用Word-Wrap
如上所述,XML属性android:scrollHorizontally="true"不起作用.然而,奇怪的是,如果通过Java完成它确实有效.这是实现无包装的必要代码:
mEditText.setHorizontallyScrolling(true);
Jor*_*sys 34
在Android 4.0+有的时候我在我的TextView红色下划线,所以我添加属性...
android:inputType="textNoSuggestions"
Run Code Online (Sandbox Code Playgroud)
textNoSuggestions:表示IME不应显示任何基于字典的单词建议.
以下是我们可以定义的可能属性列表: android:inputType
请记住该属性android:scrollHorizontally="true"不起作用,因此这是解决方案:
mEditText.setHorizontallyScrolling(true);
Run Code Online (Sandbox Code Playgroud)
小智 9
在您的Java类中,您可以添加到Edittext对象...
wire1type = (EditText)findViewById(R.id.wire1type);
wire1type.setInputType( ~(InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) );
Run Code Online (Sandbox Code Playgroud)
这将清除自动更正标志,并将在API 4中运行.
android:inputType="textMultiLine|textPhonetic"
Run Code Online (Sandbox Code Playgroud)
为我删除了所有红色下划线.
android:inputType="textMultiLine|textNoSuggestions"
Run Code Online (Sandbox Code Playgroud)
产生编译错误.
我使用Android API 1.6.
通过代码禁用拼写检查器以获取常规文本输入:
mEditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27288 次 |
| 最近记录: |