一些edittext输入后自动禁用android中的键盘
我正在尝试在某些文本后弹出键盘。 即在一些条件满足之后。 如何在android中做到这一点。 即如果(eT1的字符== et2的字符)eT1已经输入,现在在输入et2。
我用过:eT2.addTextChangedListener(new TextWatcher(){
public void onTextChanged(CharSequence s, int start,int before, int count)
{
// TODO Auto-generated method stub
String oldPass = eT1.getText().toString(); if(!oldPass.contentEquals(e2.getText().toString()))
{
View view = this.getCurrentFocus();
if(view!= null){
InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(),0); }
}
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
// TODO Auto-generated method stub
}
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
尝试这样的事情:
final EditText et1 = (EditText) findViewById(R.id.editText1);
final EditText et2 = (EditText) findViewById(R.id.editText2);
et1.setKeyListener(new KeyListener() {
public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) {
if(view.getText().equals(et2.getText()) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
return true;
}
return false;
}
}
链接地址: http://www.djcxy.com/p/16673.html
上一篇: after some edittext input automatically disable keypad in android