安卓冰淇淋三明治EDITTEXT:禁用拼写检查和自动换行 [英] Android Ice Cream Sandwich Edittext: Disabling Spell Check and Word Wrap

查看:1058
本文介绍了安卓冰淇淋三明治EDITTEXT:禁用拼写检查和自动换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然测试的Andr​​oid模拟器运行Android 4.0(冰淇淋三明治),我已经注意到,EDITTEXT做一些很奇怪的事情。

Whilst testing on the Android Emulator running Android 4.0 (Ice Cream Sandwich), I have noticed that the Edittext does some quite strange things.

首先,它强调了每一个标识为红色的拼写错误二字。我如何禁用此? 其次,虽然在布局XML我指定了安卓scrollHorizo​​ntally =真正的自动换行启用了:我怎么禁用此呢?这里是布局XML code为EDITTEXT:

Firstly, it underlines every word identified as "misspelt" in red. How do I disable this? Secondly, although in the layout XML I have specified android:scrollHorizontally="true" word-wrap is enabled: how do I disable this as well? Here is the Layout XML code for the Edittext:

    <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>

下面是拼写检查器的一个例子,我需要禁用:

Here is an example of the spell checker I need to disable:

非常感谢!

推荐答案

禁用拼写检查
为了摆脱拼写的检查必须在XML为以下指定的EditText的InputType:

Disabling Spell-Checking
In order to get rid of spell checking you must specify the EditText's InputType in the XML as the following:

安卓inputType =textNoSuggestions

不过,我需要的EditText也为多,所以我已经添加了以下行的EditText的XML:

However, my EditText needed also to be multiline, so I have added the following line to the EditText's XML:

安卓inputType =textMultiLine | textNoSuggestions

禁用自动换行
如前所述,XML属性安卓scrollHorizo​​ntally =真正的不起作用。然而,奇怪的是,如果是通过Java完成它的工作。这是必要的code实现无字包装:

mEditText.setHorizo​​ntallyScrolling(真);

Disabling Word-Wrap
As noted, the XML attribute android:scrollHorizontally="true" does not work. However, strangely, if it is done through Java it does work. Here is the necessary code to achieve no word wrapping:

mEditText.setHorizontallyScrolling(true);

这篇关于安卓冰淇淋三明治EDITTEXT:禁用拼写检查和自动换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆