-1
我想讓我的edittexf只接受阿拉伯語|波斯語字母,我寫了這段代碼,但我無法限制它。android - 如何限制edittext只接受阿拉伯語|波斯語字母
name.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
String firstChar = name.getText().toString();
char chars[] = firstChar.toCharArray();
Boolean isEnglish = true;
if (Character.UnicodeBlock.of(chars[0]) != Character.UnicodeBlock.BASIC_LATIN) {
isEnglish = false;
}
}
});
如何讓edittext只接受阿拉伯文字母?
已經回答了https://stackoverflow.com/questions/12171676/prevent-other-language-except-english-in-edittext –
可能的複製[防止在EditText中除了英文以外的其他語言](https://stackoverflow.com/questions/12171676/prevent-other-language-except-english-in-edittext) –