監聽軟鍵盤登錄按鈕和隱藏軟件鍵盤

監聽軟鍵盤登錄按鈕
  @Override
    public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
        if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
            hiddenInputMethod();
            loginAction();
        }
        return false;
    }


 /**
     * 隱藏軟鍵盤
     */
    public void hiddenInputMethod() {
        View focusView = this.getCurrentFocus();
        if (focusView != null) {
            ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(focusView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章