How do I restrict the Android keyboard presented to a user to Latin?

我的梦境 提交于 2020-01-17 04:25:06

问题


I have an application that requires that the user enter an ASCII password between dec 32 and 126. This means that only a latin character and number keyboard is valid for editing. However, when I launch my edittext, a cyrillic keyboard is presented to the user.

My question is, how do I ensure that only a latin keyboard is presented to the user?


回答1:


There is no way to force IME to a certain language/character set. However, if you set your EditText to be type password, most software keyboards will limit itself to ASCII + number. That's the closest you will get without writing your own input method.

<EditText
 android:password="true"
 ...
 />



回答2:


Try to add this to your xml:

<EditText
    android:inputType="text"
    android:digits="0,1,2,3,4,5,6,7,8,9,*,qwertzuiopasdfghjklyxcvbnm" />


来源:https://stackoverflow.com/questions/30630597/how-do-i-restrict-the-android-keyboard-presented-to-a-user-to-latin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!