Android numeric password field(Android 数字密码字段)
问题描述
我有一个 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 数字密码字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android 数字密码字段


- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01