I have an EditText with a button next to it. The button adds the keyword from the EditText to a list and clears the EditText so that the user can enter another keyword. Every time the button is pressed, the keyboard goes away. I have tried android:focusable="false"
and android:focusableInTouchMode="false"
on the button and I have tried editText.requestFocus()
in the button on click method. The keyboard still disappears. The behavior I want can be seen in the Google Messenger app and the Out of Milk app (and probably many other todo list apps).

- 8,391
- 5
- 34
- 53
-
have you also tried adding `editText.requestFocus()` at last line of button click event ? – Shree Krishna Apr 03 '16 at 04:03
-
@ShreeKrishna that doesn't work – cambunctious Apr 03 '16 at 04:10
-
The keyboard is already gone before the button click method is called. An ideal solution would prevent the keyboard from hiding by that time. – cambunctious Apr 03 '16 at 04:11
-
How is it possible ? you mean keyboard hides while writing something ? – Shree Krishna Apr 03 '16 at 04:12
-
No. I set a breakpoint in the button click method. – cambunctious Apr 03 '16 at 04:14
-
I simply tested like you said and working properly, So that I need to see your codes. Can you please post that. – Shree Krishna Apr 03 '16 at 04:15
-
Post your code what exactly you doing??? – Pankaj Apr 03 '16 at 04:29
-
you could choice this solution http://stackoverflow.com/questions/1509719/android-how-to-make-the-keypad-always-visible – illusionJJ Apr 03 '16 at 09:06
2 Answers
Can't comment yet, but I've used the first code block in an app I have for adding a filter window (consisting of an edit text, a set of toggle buttons and a set of check boxes) in a click listener and showing the keyboard. I assume it would work with the text view already visible. Just getting focus doesn't open the keyboard automatically, or else it didn't for me either.
http://developer.android.com/training/keyboard-input/visibility.html
Will add code tomorrow if still open.

- 1,430
- 1
- 11
- 18
I had an override dispatchTouchEvent
in my activity to do the exact opposite thing. I wanted the keyboard to disappear when tapping outside of another EditText. I could share the code but I think it is arbitrary. In the end, it helped a lot to really understand touch events by reading this article.

- 8,391
- 5
- 34
- 53