Create Passcode view in Android

To capture the backspace,its actually the delete key in android. you can capture it via

editText.setOnKeyListener(new OnKeyListener() {                 
    @Override
    public boolean onKey(View v, int keyCode, KeyEvent event) {
         if(keyCode == KeyEvent.KEYCODE_DEL){  
             //delete key pressed
             }
    return false;       
        }
});

To hide the keyboard try this

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);

Leave a Comment