Skip to content Skip to sidebar Skip to footer

How To Hide Keyboard On Enter Key

i have an activity with four edittext and i want to hide keyboard when users finish to use one of the four edittext. if i click enter on keyboard, it will focus another edittext an

Solution 1:

I am not sure but you should try this code:-

youredittext.setOnEditorActionListener(newTextView.OnEditorActionListener() {

    @OverridepublicbooleanonEditorAction(TextView v, int keyCode, KeyEvent event) {
        if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
            // hide virtual keyboardInputMethodManagerimm= (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(youredittext.getWindowToken(), 0);
            returntrue;
        }
        returnfalse;
    }
});

I hope this will help..

Solution 2:

Post a Comment for "How To Hide Keyboard On Enter Key"