Closing keyboard after button click (breaks if no EditText is focused on)
I put this on my button listener:
InputMethodManager inputManager
=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
It works perfectly for when the keyboard is up: it closes the keyboard and
then continues its execution. The problem is that when no EditText was
ever pressed (none of them are highlighted/focused on), it breaks and the
app "stops working".
I guess it would be nice if I could check if an EditText had ever been
pressed.
No comments:
Post a Comment