Fred J. Fred J. - 1 year ago 132
Android Question

android:inputType="numberDecimal" vs. InputType.TYPE_NUMBER_FLAG_DECIMAL

The following condition evaluates to false. Isn't suppose to be true?

editText.getInputType() == InputType.TYPE_NUMBER_FLAG_DECIMAL

specially when in the xml file, I have


Debugging shows that

editText.getInputType() = 8194



What am I missing?

Answer Source

numberDecimal refers to both TYPE_CLASS_NUMBER and TYPE_NUMBER_FLAG_DECIMAL. So when you compare, you need to do this.

editText.getInputType() == (InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download