Home » Android » Way to hide softkeypad provided not effecting the features of the edittext in android

Way to hide softkeypad provided not effecting the features of the edittext in android

Posted by: admin May 14, 2020 Leave a comment


I have hidden soft keypad because I have custom keypad on the app. When the edittext is clicked, soft keypad shouldn’t pop up. So, I have tried so many ways from the sources, but nothing worked except the editText.setFocusable(false); . But now the problem is edittext is not getting highlighted when I clicked it and even cursor is not visible. I have tried using InputManager, android:windowSoftInputMode="stateAlwaysHidden in the manifest and referred many like link 1 , link 2 etc., but these techniques atleast don’t even hide the soft keypad on my app. Finally I got this through setFocusable, but there is a highlighting problem and cursor invisible problem and even requestFocus() in the onClickListener didn’t work. Can someone give exact solution for this problem? Code snippet is appreciated.

How to&Answers:

Try this one in activity class


This one is avoiding of soft key pad


please use this in manifest:



You ddont need to add any method in menifist. just add this code.. It will automaticlly hide when you click on button to get value.

Want to hide softkeyboard use this code in your click listener method.

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

i hope this code work fine.


Try this:

InputMethodManager imm = (InputMethodManager)getSystemService( Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFomWindow( edittext.getWindowToken(), 0);


how about if you editText.setOnTouchListener and when you create the new OnTouchListener do nothing something like:

editText.setOnTouchListener(new OnTouchListener(){

    public boolean onTouch(View v, MotionEvent event) {
        return true;