I have an Android application with a form. When the user sends in the information by clicking on "Send", the app validates the form. If the problem is found, it scrolls up and shows a certain textView.
But how do I clear the keyboard? It takes in half of my screen.
To show the keyboard:
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
And to hide:
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editText.getWindowToken(), 0);
This code was taken from http://www.androidguys.com/2009/11/12/how-to-showhide-soft-keyboard-programmatically-dev-tips-tools/