TrustNoOne
TrustNoOne

Reputation: 595

disable "spell checking" on textView

This is more a 'is there a more appropriate way' question as I have found a work around.

Some of my table headers are being picked up as spelling errors and underlined in red. Of course, that is not what I would like to see. I have found that using

android:inputType="textNoSuggestions"

does disable the spell check markings. I find it odd (bug?) that this is necessary as the docs state:

inputType: The type of data being placed in a text field, used to help an input method decide how to let the user enter text.

and there is no input associated with just textView. So is this the only/more appropriate way of avoiding the spell check and also, is this a bug that it is spell checking non-input fields?

UPDATE: per request this is sample xml

<TextView
        android:text="ID#"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:typeface="monospace"
        android:textSize="14sp"
        android:digits="4"
        android:textAlignment="gravity"
        android:layout_weight="5"
        android:gravity="left"
        android:singleLine="true"
        android:phoneNumber="true"
        android:inputType="textNoSuggestions|none">

</TextView>

Upvotes: 9

Views: 10560

Answers (3)

Tanner Assenmacher
Tanner Assenmacher

Reputation: 11

On later android studio versions try:

android:autoText="true"

inside of the (or any input) in the xml. On newer versions try:

android:inputType="textNoSuggestions"

Upvotes: 0

Adam
Adam

Reputation: 26907

I know this is an old thread but removing the following from content XML worked for me:

    android:autoText="true"

Upvotes: 2

Bryan Herbst
Bryan Herbst

Reputation: 67189

First, I would try removing the android:digits, android:phoneNumber, and android:inputType attributes.

All of those are more intended for use with fields that allow input (such as EditTexts). It also doesn't look like you are using the android:digits attribute correctly, as the string you provide defines the only allowable characters.

In essence, this combination of attributes is telling Android that your TextView accepts input in the form of telephone numbers that contain only the number 4, that this TextView doesn't accept input of any type, and Android should not provide spellcheck suggestions.

If you are setting the content of the TextView yourself, there really is no reason to try to restrict the content of the TextView with flags such as android:phoneNumber since you are the one controlling that.

Upvotes: 4

Related Questions