Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

android:inputType="numberDecimal"

Debugging shows that

editText.getInputType() = 8194

and

InputType.TYPE_NUMBER_FLAG_DECIMAL = 8192

What am I missing?

like image 624
Fred J. Avatar asked Aug 10 '15 07:08

Fred J.


People also ask

What is inputType in android?

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.

What is textWebPassword?

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).


1 Answers

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)
like image 159
Anitha Manikandan Avatar answered Sep 30 '22 18:09

Anitha Manikandan