Tuesday, 7 January 2014

Easy way to hide softinputmode softinputkeyboard example

Here is the code:
 public void hideKeyboard(Activity activity) {  
   activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);  
   InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);  
   View cur_focus = activity.getCurrentFocus();  
   if (cur_focus != null) {  
     inputMethodManager.hideSoftInputFromWindow(cur_focus.getWindowToken(), 0);  
   }  
 }