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
android:inputType="numberDecimal"
Debugging shows that
editText.getInputType() = 8194
and
InputType.TYPE_NUMBER_FLAG_DECIMAL = 8192
What am I missing?
The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.
android:inputType="textWebPassword" : Corresponds to TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_PASSWORD and has the same behaviour as android:inputType="textPassword" but it is intended to be used in a web form i.e. inside a browser page (any web form control that takes input from a user).
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With