android调用键盘

显示键盘
private void showInputMethod(Context context) {
    //自动弹出键盘
    InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    //强制隐藏Android输入法窗口
    // inputManager.hideSoftInputFromWindow(edit.getWindowToken(),0);
}
隐藏键盘
public static void hideKeyboard(View v){
    InputMethodManager inputMethodManager = ( InputMethodManager) v.getContext( ).getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
        inputMethodManager.hideSoftInputFromWindow( v.getApplicationWindowToken() , 0 );
    }
}

你可能感兴趣的:(Android)