禁止在EditText中使用除英语以外的其他语言 [英] Prevent other language except English in EditText

查看:73
本文介绍了禁止在EditText中使用除英语以外的其他语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android应用程序具有一个EditText字段,用户可以在其中输入内容.但是现在我希望用户不能输入除英语之外的其他输入(即日语,日语).

My android app has an EditText field where user can give input. But now i want user can't give input other (i.e Japanese, chain's) than English language.

推荐答案

您可以限制用户在编辑文本中仅输入特定字符,

you can limit the user to enter only specific characters in the edit text,

<EditText
    android:id="@+id/nameText"
    android:layout_width="177dp"
    android:layout_height="wrap_content"
    android:inputType="text"
    android:digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" />

通过这种方式,用户只能输入英语单词和空格,而不能输入其他内容.

By this, the user could only enter English words and space, nothing else..

这篇关于禁止在EditText中使用除英语以外的其他语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆