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