EditText without auto-correction, etc

后端 未结 4 1635
情歌与酒
情歌与酒 2020-12-05 22:23

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 so

相关标签:
4条回答
  • 2020-12-05 23:06

    Try this:

    android:inputType="textFilter"
    

    If that doesn't work, try:

    android:inputType="textFilter|textNoSuggestions"
    
    0 讨论(0)
  • 2020-12-05 23:12

    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

    0 讨论(0)
  • 2020-12-05 23:15

    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 讨论(0)
  • 2020-12-05 23:16

    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);
    
    0 讨论(0)
提交回复
热议问题