Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Keyboard Dismissal

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!

like image 751
embersofadyingfire Avatar asked Jan 26 '13 18:01

embersofadyingfire


People also ask

How do I hide the soft keyboard on Android after clicking outside Edittext?

and put the following code in the onTouch method. InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); imm. hideSoftInputFromWindow(getCurrentFocus(). getWindowToken(), 0);

How do you hide the keyboard on a button click in flutter?

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.


1 Answers

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).

like image 197
Swayam Avatar answered Nov 02 '22 20:11

Swayam