Edit Text without Autocorrect

2019-01-28 02:28发布

I want an EditText without the autocorrection. I have set the textNoSuggestions inputType, as shown:

 <EditText
    android:id="@+id/txtTarga"
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="Targa"
    android:inputType="textNoSuggestions|textCapCharacters" >

The capitalize flag works, but it is still autocorrecting.

How can I disable it?

4条回答
不美不萌又怎样
2楼-- · 2019-01-28 02:33

inputType textVisiblePassword will do the trick (most of the times, because as Commonsware pointed out, it stays a request and you'll might find yourself finding devices where it works, and devices where it doesn't work)

查看更多
时光不老,我们不散
3楼-- · 2019-01-28 02:34

In Xml

<EditText
        android:id="@+id/password"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:hint="password"
        android:imeOptions="actionDone"
        android:inputType="textPassword"
        android:singleLine="true"
        />

In java source code

    // casting done from EditText to TextView

    TextView mPassword = (TextView) findViewById(R.id.password);

No idea why is this. But works fine.

查看更多
SAY GOODBYE
4楼-- · 2019-01-28 02:39
android:inputType="textNoSuggestions"

according to this, inputType attribute may or may not be supported by some devices .

However, this seems to work more often

android:inputType="textNoSuggestions|textVisiblePassword"
查看更多
我命由我不由天
5楼-- · 2019-01-28 02:55

You could try by code, something like this:

EditText edittext = (EditText)findViewById(R.id.txtTarga);
edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
查看更多
登录 后发表回答