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.
Asked
Active
Viewed 360 times
11

Community
- 1
- 1

Enthusiast
- 249
- 1
- 8
-
I think this will help http://stackoverflow.com/questions/5803193/android-disable-soft-keyboard-at-all-edittexts – Rahul Sep 08 '12 at 06:50
-
I used `.setInputType(InputType.TYPE_NULL)` and have your problem. call me if you found the solution. – Bob Sep 08 '12 at 06:52
-
@Rahul I have referred this too previously. As you can see at the end, the OP in that link didn't get the output that he wanted with those answers and Neither did I after trying those. – Enthusiast Sep 08 '12 at 07:27
-
@breceivemail Okay. Will let you know if I found the solution. You are completely disabling the edittext by TYPE_NULL so that in the edittext, nothing can be entered. – Enthusiast Sep 08 '12 at 07:36
-
i had posted solution there check it http://stackoverflow.com/questions/1994732/how-to-hide-the-virtual-keyboard/21878009#21878009 – Muhammad Usman Ghani Feb 20 '14 at 19:02
-
The Question is a duplicate of [Android Hide Soft Keyboard from EditText while not losing cursor](http://stackoverflow.com/q/13586354/7550472). The solution for this is to set the flag `textIsSelectable` in EditText to **true**. For more details, check the detailed answer here at : [http://stackoverflow.com/a/42180201/7550472](http://stackoverflow.com/a/42180201/7550472) – Kaushik NP Feb 11 '17 at 20:06
-
Possible duplicate of [Android Hide Soft Keyboard from EditText while not losing cursor](http://stackoverflow.com/questions/13586354/android-hide-soft-keyboard-from-edittext-while-not-losing-cursor) – Kaushik NP Feb 12 '17 at 18:54
5 Answers
1
Try this one in activity class
getwindow().setsoftInputMode(winowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
This one is avoiding of soft key pad

Adi Lester
- 24,731
- 12
- 95
- 110

Kiran Android
- 286
- 1
- 3
- 6
-
This doesn't work in my case, if you see the links provided above. Thanks, though. – Enthusiast Sep 15 '12 at 03:18
1
Try this:
InputMethodManager imm = (InputMethodManager)getSystemService( Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFomWindow( edittext.getWindowToken(), 0);

Stephan
- 41,764
- 65
- 238
- 329
1
please use this in manifest:
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="stateHidden"

Daniel
- 10,864
- 22
- 84
- 115

Ashish Agrawal
- 1,977
- 2
- 18
- 32
1
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); imm.hideSoftInputFomWindow(edittext.getWindowToken(),0);
i hope this code work fine.

Talal Qaboos
- 48
- 6
1
how about if you editText.setOnTouchListener and when you create the new OnTouchListener do nothing something like:
editText.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});

Omid Aminiva
- 667
- 5
- 14