How to force English keyboard in android EditText(如何在 android EditText 中强制使用英文键盘)
问题描述
我知道如何强制输入数字、文本等,但是如果我的数据库字段只能接受英文字符,是否有一个标志或 IME 选项让我强制 EditText 只接受某些语言,如英语?当然,我可以检查并通知用户输入错误,但这并不完全是用户友好的......
I know how to force numbers, texts etc.., but is there a flag or IME options for me to force the EditText to accept only certain language like English in case my DB fields can accept only English characters? of course I can check and notify the users on bad input but that's not exactly user friendly....
在 EditText 上实现我自己的过滤器也是可能的,但我不确定它是否会强制键盘布局本身使用我需要的语言.
Implementing my own filter on the EditText might also be possible but I'm not sure it will force the keyboard layout itself to be in the language I need.
有什么想法吗?
推荐答案
无论如何你都应该过滤输入.强制英文键盘不会强制用户只使用英文字母.用户仍然可以长按字符或使用非英文硬件键盘.
You should probably filter the input anyways. Forcing English keyboard doesn't force user to use only English letters. User can still long press a character or have a non-english hardware keyboard.
您可以收听文本更改事件并拒绝此时您的数据库不接受的所有字符.
You could listen to text change events and reject all characters that are not accepted by your DB at that point.
这篇关于如何在 android EditText 中强制使用英文键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 android EditText 中强制使用英文键盘


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