Example usage for android.view.inputmethod InputMethodManager toggleSoftInput

List of usage examples for android.view.inputmethod InputMethodManager toggleSoftInput

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager toggleSoftInput.

Prototype

public void toggleSoftInput(int showFlags, int hideFlags) 

Source Link

Document

This method toggles the input method window display.

Usage

From source file:Main.java

public static void delKeyBoard(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
    }//from w w  w  .j  a v  a2 s .  com
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.CUPCAKE)
public static void toggleSoftInput(Context context, EditText edit) {
    edit.setFocusable(true);/* w w  w  .  j av  a 2s  .co m*/
    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

public static void showKeyboard(Activity activity) {
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
    }//from w  ww  .ja va2s .  com
}

From source file:Main.java

public static void showSoftKeyBoard(EditText etInput) {
    InputMethodManager inputManager = (InputMethodManager) etInput.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    //            inputManager.showSoftInput(etInput, 0);
}

From source file:Main.java

public static void hideKeyboard(Activity activity) {
    InputMethodManager m = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (m != null) {
        m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from www.  j  ava 2s . c o m*/
}

From source file:Main.java

public static void toggleKeyboard(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
    }//  w ww  . ja va2 s . co m
}

From source file:Main.java

/**
 * Toggle Soft Input.//from w  w  w .  j  a v a  2s  .co m
 * @param context
 */
public static void toggleSoftInput(Context context) {
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:Main.java

/**
 * Toggle Soft Input.//from ww w.j a v  a 2 s  .c  om
 * @param context
 * @param showFlags
 */
public static void toggleSoftInput(Context context, int showFlags) {
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(showFlags, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:Main.java

/**
 * Toggle Soft Input./*from ww w  .j  ava2s  .  c  o  m*/
 * @param context
 * @param showFlags
 * @param hideFlags
 */
public static void toggleSoftInput(Context context, int showFlags, int hideFlags) {
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(showFlags, hideFlags);
}

From source file:Main.java

public static void showInputKeyboard(Context context) {
    try {//from w  w  w  . j  a va  2  s. c  o m
        View view = ((Activity) context).getWindow().peekDecorView();
        if (view != null && view.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) context
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
            imm.showSoftInput(view, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}