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 数字密码字段
基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
