問題描述
我有一個 EditText 字段,它需要是一個數字密碼字段.在縱向模式下一切正常;不在風景中.當用戶選擇 EditText 字段時,UI 會放大該字段,并且當我鍵入時,所有字符都可見.
I have an EditText field which needs to be a numeric password field. Everything works OK in portrait mode; not in landscape. When the user selects the EditText field, the UI zooms into the field and when I type all the characters are visible.
我還需要一個數字鍵盤.我嘗試將輸入類型設置為文本密碼|數字.如果我刪除數字"選項一切正常;否則不行.
I need a numeric keyboard also. I tried setting the input type to text password|number. If I remove "number" option everything works right; otherwise no.
有什么建議嗎?
推薦答案
這個問題可以在不使用已棄用的 android:password
的情況下解決.使用以下代碼片段,但不要顛倒調用順序:
This problem can be solved without using deprecated android:password
. Use the following code snippet, but do not reverse the sequence of calls:
EditText editText = (EditText) findViewById(R.id.MyEditText);
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
這篇關于Android 數字密碼字段的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!