各位 我现在在做一款应用 产品经理要求在输入字符的时候 当判断输入了4个汉字以后会自动收起软键盘 于是我做了判断 当Edittext 监听到输入的字符长度为4的时候 让软键盘收起 但现在发现有的手机上输入4个英文字符的时候也会收起软键盘,这不是我想要的 请问我该怎么做。以下代码是我的方法:
editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub if (editText.getText().toString().length()==4) { // editText.clearFocus(); InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(),0); } }