欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Android点击空白区域隐藏键盘,android空白,/** * 点击

来源: javaer 分享于  点击 13413 次 点评:15

Android点击空白区域隐藏键盘,android空白,/** * 点击


/**     * 点击空白区域隐藏键盘.     * @param event the event     * @return true, if successful     */    @Override    public boolean onTouchEvent(MotionEvent event) {        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);        if (event.getAction() == MotionEvent.ACTION_DOWN) {            if (EBDocuSearchActivity.this.getCurrentFocus() != null) {                if (EBDocuSearchActivity.this.getCurrentFocus().getWindowToken() != null) {                    imm.hideSoftInputFromWindow(EBDocuSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);                }            }        }        return super.onTouchEvent(event);    }``````java/**隐藏键盘 */    protected void hideInputKeyboard(View v) {        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);    }    /**弹起键盘 */    protected void showInputKeyboard(View v) {        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);        imm.showSoftInput(v, 0);    }
相关栏目:

用户点评