Вопрос

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!

Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top