Code example for InputMethodManager

Methods: toggleSoftInput

0
     * @param view 
     */ 
    private static void showKeyboard(View view) {
        Context context = view.getContext();
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    } 
 
    /** 
     * Hides the keyboard. 
     * 
     * @param view 
     */ 
    private static void hideKeyboard(View view) {
        Context context = view.getContext();
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } 
 
    /** 
     * Callbacks for changes to the query text.