問題描述
剛剛注意到 android:password 已被棄用,我們應該使用 android:inputType.通過在我的 xml 中設置來試驗它
Just noticed that android:password has been deprecated, and we should be using android:inputType. Was experimenting with it by setting in my xml
android:inputType="textPassword"
確實是這樣的
android:password="true"
對于 EditText,但似乎如果我使用 android:inputType,android:hint 將不起作用.EditText 將為空白.使用 android:password 和 android:hint 時沒有這樣的問題.我在這里遺漏了一些關于 android:inputType 的內容嗎?
for EditText, but it seems that if I use android:inputType, android:hint will not work. The EditText will be blank. There is no such issues when using android:password with android:hint. Am I missing something here about android:inputType?
推薦答案
剛剛偶然發現了答案.android:inputType="textPassword"
確實適用于 android:hint
,與 android:password
相同.唯一的區別是當我使用 android:gravity="center"
時,如果我使用的是 android:inputType
,提示將不會顯示.結案!
Just stumbled on the answer. android:inputType="textPassword"
does work with android:hint
, same as android:password
. The only difference is when I use android:gravity="center"
, the hint will not show if I'm using android:inputType
. Case closed!
這篇關于帶有 android:hint 的 Android EditText 密碼的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!