2012年8月26日 星期日

[Android] Hide Input Method Panel

In many cases, we type something in the EditText, and then click the Button, but the Input Method Panel doesn't hide itself. Here's the solution:

Add these lines to your Button function, and the panel will disappear at the moment you click!
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
if(imm != null) imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);

沒有留言:

張貼留言