Widget properties: XML layout vs code

Just stumbled upon another annoyance: you can’t trust XML properties. Let’s take the EditText. We could try to disable dictionary suggestions:

android:inputType="textNoSuggestions"

Well does it work? Probably not, at least not with the devices I tested. But when we do exactly the same in code:

promoCodeEditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

It works like a charm! Documentation says clearly that these two are equivalent:

textNoSuggestions  

Can be combined with text and its variations to indicate that the IME should not show any dictionary-based word suggestions. Corresponds toTYPE_TEXT_FLAG_NO_SUGGESTIONS.

Well, not quite… 🙂