0
我想知道在edittext中输入文本的区域设置! 但是我试图获得键盘语言环境,但这没有帮助。 我不想在edittext中键入英文,所以帮助我! 我想让用户知道他/她不能输入英文!如何获得android的语言环境?
对不起,我的英语不好!
这里是我的代码:
edtUsernameLogin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().isEmpty()) {
mtfUsernameLogin.setLabelColor(G.resources.getColor(R.color.cpb_white), "نام کاربری");
} else {
String locale = G.inputMethodManager.getCurrentInputMethodSubtype().getLocale();
if (locale.equals("fa") || locale.equals("ar")) {
mtfUsernameLogin.setLabelColor(G.resources.getColor(R.color.sPink), "نام کاربری باید انگلیسی باشد !");
} else {
mtfUsernameLogin.setLabelColor(G.resources.getColor(R.color.sGreen), "نام کاربری");
}
}
}
});
如果我理解正确的话,ü要打开键盘作为每个手机的语言? –
恕我直言,只有通过编辑文本中输入的文本才能获取默认设备语言或检测语言 – uguboz
您究竟在做什么?很难阻止用户输入英文,如果他决定。你可以设置一个不允许使用拉丁字符的过滤器,但只有当你的语言不使用它们时才会起作用,并且会对双语用户或必须使用英语单词出于技术或行话目的的用户感到恼火。 –