android 软件盘打开 关闭

  1. 点击按钮关闭软件盘  

    public static void hideSoftInput(Activity acitivity) {
    LogUtil.d("hideSoftInput");
    InputMethodManager imm = (InputMethodManager) acitivity
    .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(acitivity.getWindow().getDecorView()
    .getApplicationWindowToken(),
    InputMethodManager.HIDE_NOT_ALWAYS);
    }

  2. 指定EditText 弹出软键盘   

    public static void showSoftInput(EditText et) {
    LogUtil.d("showSoftInput");
    et.requestFocus();
    InputMethodManager imm = (InputMethodManager) et.getContext()
    .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(et, InputMethodManager.RESULT_UNCHANGED_SHOWN);

    }

posted on 2013-07-12 17:35  杀#嘻哈  阅读(392)  评论(0编辑  收藏  举报

导航