Domanda

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!

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top