List of usage examples for android.content Context INPUT_METHOD_SERVICE
String INPUT_METHOD_SERVICE
To view the source code for android.content Context INPUT_METHOD_SERVICE.
Click Source Link
From source file:Main.java
public static void hideKeyboard(Context context, View view) { if (context == null) { throw new IllegalArgumentException("context cannot be null"); }//from www . j a va 2 s . c om if (view == null) { throw new IllegalArgumentException("view cannot be null"); } InputMethodManager mgr = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
public static void showInputMethodManager(final EditText editText) { Timer timer = new Timer(); timer.schedule(new TimerTask() { public void run() { InputMethodManager inputManager = (InputMethodManager) editText.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(editText, 0); }/*from w w w. j a v a 2s . c om*/ }, 200); }
From source file:Main.java
public static void hideKeys(Context context, TextView textView) { textView.setCursorVisible(false);//from w w w. j a v a2 s. c o m InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(textView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }
From source file:Main.java
public static void hideKeyBoard(final Activity activity) { if (activity == null) return;/* w ww .ja v a 2 s . c om*/ activity.runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub InputMethodManager mgr = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); } }); }
From source file:Main.java
public static void hideKeyboard(@NonNull View view, @NonNull Context activity) { InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0); }
From source file:Main.java
/** * close the SoftInput//from w w w .java2s .c o m * * @param activity */ public static void closeSoftInput(Activity activity, EditText mEditText) { if (activity == null || mEditText == null) { return; } InputMethodManager inputMethodManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null && inputMethodManager.isActive()) { inputMethodManager.hideSoftInputFromWindow(mEditText.getWindowToken(), 0); } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.CUPCAKE) public static void toggleSoftInput(Context context, EditText edit) { edit.setFocusable(true);//w ww. j av a 2 s .c om edit.setFocusableInTouchMode(true); edit.requestFocus(); InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); }
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 ww w .ja v a 2s .c o m*/ 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
@TargetApi(Build.VERSION_CODES.CUPCAKE) public static void showSoftInput(Context context, EditText edit) { edit.setFocusable(true);//from ww w . ja v a 2s .co m edit.setFocusableInTouchMode(true); edit.requestFocus(); InputMethodManager inputManager = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(edit, 0); }
From source file:Main.java
/** * Dismiss the keyboard for the given activity. * @param activity to dismiss associated keyboard for. *//*from www. j ava 2 s .c o m*/ public static void hideKeyboard(@NonNull Activity activity) { InputMethodManager inputManager = (InputMethodManager) activity .getSystemService(Context.INPUT_METHOD_SERVICE); View focus = activity.getCurrentFocus(); if (focus != null) { inputManager.hideSoftInputFromWindow(focus.getWindowToken(), 0); } }