EditView手动设置弹出键盘和收起键盘

1、弹出键盘

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

2、收起键盘

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

 

上一篇:Kubernetes 概述


下一篇:Leetcode之动态规划(DP)专题-72. 编辑距离(Edit Distance)