I have an Activity
with an EditText
, a button and a ListView
. The purpose is to type a search screen in the EditText
, press the button and have the search results populate this list.
This is all working perfectly, but the virtual keyboard is behaving strange.
If I click the EditText
, I get the virtual keyboard. If I click the "Done" button on the virtual keyboard, it goes away. However, if I click my search button before clicking "Done" on the virtual keyboard, the virtual keyboard stays and I can't get rid of it. Clicking the "Done" button does not close the keyboard. It changes the "Done" button from "Done" to an arrow and remains visible.
Thanks for your help
You use this code in your button click event
Kotlin example:
from Fragment:
from Activity:
Try this...
For Showing keyboard
For Hide keyboard
You should implement
OnEditorActionListener
for your EditViewAnd you hide keyboard by:
You should also fire keyboard hiding in your button using
onClickListener
Now clicking 'Done' on virtual keyboard and button will do the same - hide keyboard and perform click action.
Add the following code inside your button click event: