Kevin Westwood
Kevin Westwood

Reputation: 7789

How do I specify EditText inputType as number and password?

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?

Upvotes: 29

Views: 50314

Answers (3)

Bobbake4
Bobbake4

Reputation: 24847

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

Upvotes: 2

woyaru
woyaru

Reputation: 5624

Set android:inputType="numberPassword"

See this Link

Upvotes: 47

Okan Kocyigit
Okan Kocyigit

Reputation: 13421

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.

Upvotes: 18

Related Questions