List of usage examples for android.view.inputmethod InputMethodManager hideSoftInputFromWindow
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags)
From source file:Main.java
/** * Force hide soft keyboard with specific flag. * @param context Context to get system service input method. * @param viewBinder View has current focus. Can achived by View.getWindowToken(). * @param flags InputMethodManager flags. *///www . j a va 2 s . c o m public static void hideKeyboard(Context context, View viewBinder, int flags) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(viewBinder.getWindowToken(), flags); }
From source file:Main.java
public static void HideKeyboard(View v) { InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive()) { imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0); }// www.j a va 2 s . c o m }
From source file:Main.java
public static void hideSoftKeyboard(Activity activity) { if (activity != null) { InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); }//from www .j a va2 s.c om }
From source file:Main.java
public static void hideInput(View view) { try {/*from w w w .j av a 2s . c o m*/ InputMethodManager imm = (InputMethodManager) view.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void hideKeyboard(Context mContext, View mEditText) { @SuppressWarnings("static-access") InputMethodManager imm = (InputMethodManager) mContext.getSystemService(mContext.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.CUPCAKE) public static void hideSoftInput(Context context, EditText edit) { edit.clearFocus();//from www . j a va 2s .c om InputMethodManager inputmanger = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0); }
From source file:Main.java
public static void hideSoftInput(Context context, View focusView) { InputMethodManager imm = from(context); if (imm.isActive()) { IBinder token = focusView.getWindowToken(); imm.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS); }//from w w w .j a v a 2s . c o m }
From source file:Main.java
/** * Force hide soft keyboard with hide flag = 0. * @param context Context to get system service input method. * @param viewBinder View has current focus. *//*from w w w .j ava 2s . c om*/ public static void forceHideSoftInput(Context context, View view) { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
/** * Dismiss the keyboard if it is displayed by any of the listed views * @param views - a list of views that might potentially be displaying the keyboard *//*from w ww . j a v a 2 s . c o m*/ public static void hideSoftInputForViews(Context context, View... views) { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); for (View v : views) { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } }
From source file:Main.java
/** * Hides the keyboard while switching among fragments. * /* w w w . ja v a 2 s. com*/ * @param context of activity. */ public static void hideKeyboard(Context context) { try { InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(((Activity) context).getCurrentFocus().getWindowToken(), 0); } catch (Exception ex) { } }