EditView manually set the pop-up keyboard and the keyboard away

1, the pop-up keyboard

    fun showKeyboard() {
        edit.setFocusable(true);
        edit.setFocusableInTouchMode(true)
        edit.requestFocus();
        var imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        imm.showSoftInput(edit, 0)
    }

2. Fold the keyboard

    fun hideKeyboard() {
        dit.setFocusable(false)
        edit.setFocusableInTouchMode(false)
        var imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        imm.hideSoftInputFromWindow(edit.windowToken, 0)
    }

 

Guess you like

Origin www.cnblogs.com/haihai88/p/11325256.html