开发者

EditText without auto-correction, etc

My EditText needs to accept input consisting of partial words, names开发者_如何学编程, etc. At least on my HTC Desire, this is difficult since the keyboard wants to suggest and/or correct some entries (e.g., changes "gor" to "for"). I tried setting textNoSuggestions on the view, but that doesn't fix it.

Any simple solution to this?


Try this:

android:inputType="textFilter"

If that doesn't work, try:

android:inputType="textFilter|textNoSuggestions"


You can do this from the code. Set the input type of the EditText like below:

txtEmail = (EditText) findViewById(R.id.txtEmail);
txtEmail.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

For a list of all the available input type options see http://developer.android.com/reference/android/text/InputType.html


The other suggestions are correct, but SwiftKey has decided it will ignore the inputtype values "in response to user requests". While I agree this is a bad idea since it contradicts the Google guidelines and developers usually have a good reason for disabling auto-correction (like username fields, family names and so on), it still is the most used keyboard application for Android devices, so this can be a big problem.

The workaround is to use either

android:inputType="textVisiblePassword"

or

.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);


Try this if you want a multi-line EditText without displaying the underlines (auto correct):

    myEditText.setInputType(InputType.TYPE_CLASS_TEXT | 
       InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Here's XML for that: android:inputType="textNoSuggestions|textMultiLine".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜