after some edittext input automatically disable keypad in android

I am trying to popdown Keyboard after some text. ie after some condition fulfilled. how to do this in android. ie if(characters of eT1==Characters of et2) eT1 is already inputed, now in et2 inputing.

i have used: 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/16674.html

上一篇: 如何检测textview中的键盘语言?

下一篇: 一些edittext输入后自动禁用android中的键盘