29

I have the following:

<EditText
    android:inputType="number"
    android:password="true"
    ....
</EditText>

I'm getting a warning that "android:password" is deprecated and that I should use inputType instead. Is there a way to specify inputType as number and password?

Kevin Westwood
  • 7,739
  • 8
  • 38
  • 52
  • see this [question][1] its exactly what you want [1]: http://stackoverflow.com/questions/2420181/android-numeric-password-field – confucius Mar 26 '12 at 22:05

3 Answers3

47

Set android:inputType="numberPassword"

See this Link

Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
woyaru
  • 5,544
  • 13
  • 54
  • 92
18

you should use TYPE_CLASS_NUMBER.

EDIT:

As this answer

android:inputType="textPassword|number" 

ignore textPassword and only accept number but not password.

So you should use android:inputType="textPassword|number" with android:password="true".

that seems to be the only solution.

Community
  • 1
  • 1
Okan Kocyigit
  • 13,203
  • 18
  • 70
  • 129
2

Just set your input type to this android:inputType="textPassword|number"

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
Bobbake4
  • 24,509
  • 9
  • 59
  • 94