How do I specify EditText inputType as number and password?

别等时光非礼了梦想. 提交于 2019-12-28 16:31:17

问题


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?


回答1:


Set android:inputType="numberPassword"

See this Link




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/9880516/how-do-i-specify-edittext-inputtype-as-number-and-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!