Android Ice Cream Sandwich Edittext: Disabling Spell Check and Word Wrap

前端 未结 7 1811
-上瘾入骨i
-上瘾入骨i 2020-12-23 13:42

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

Firstly, it underlin

相关标签:
7条回答
  • 2020-12-23 14:18
    android:inputType="textMultiLine|textPhonetic"
    

    removed all red underlines for me.

    android:inputType="textMultiLine|textNoSuggestions"
    

    produces compilation error.

    I use Android API 1.6.

    0 讨论(0)
  • 2020-12-23 14:19

    remove android:inputType="" and all should be well.

    0 讨论(0)
  • 2020-12-23 14:21

    Disabling the spell checker for general text input via code:

    mEditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    
    0 讨论(0)
  • 2020-12-23 14:22

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

    android:inputType="textNoSuggestions"

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

    android:inputType="textMultiLine|textNoSuggestions"

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

    0 讨论(0)
  • 2020-12-23 14:28

    To disable line wrapping you have to wrap (pun not intended) your EditText with an HorizontalScrollView and set your layout_width to match_parent.

    0 讨论(0)
  • 2020-12-23 14:29

    In your Java class you can add to the Edittext object...

      wire1type = (EditText)findViewById(R.id.wire1type);
      wire1type.setInputType( ~(InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) );
    

    This clears out the autocorrect flag and will work in API 4.

    0 讨论(0)
提交回复
热议问题