I have several EditText objects in an app I'm working on, and need to learn how to dismiss the keyboard when the user is done entering text, so that buttons being blocked by the keyboard on the screen are visible again, and ready for action.
In Xcode, I've used the ResignFirstResponder method to do this when, for example, the "Done" button is clicked on the keyboard by the user. I'm assuming this is possible in Android as well, but I'm not sure. I appreciate any help!
and put the following code in the onTouch method. InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow(getCurrentFocus(). getWindowToken(), 0);
TextField is a very common widget in Flutter. When you click on the TextField it opens up the on-screen keyboard. To hide/dismiss the keyboard you have to press the back button in Android and the done button (inside the onscreen keyboard) in iOS.
Code to hide the Virtual Keyboard :
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
Put it inside the onClick() of your "Done" button and you will have reasons to believe that Android is as powerful as Xcode (if not more).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With