美文网首页
Android开发点软键盘完成收起软键盘

Android开发点软键盘完成收起软键盘

作者: 你的益达233 | 来源:发表于2022-07-30 17:46 被阅读0次

直接上代码:

etNickname.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if(actionId == EditorInfo.IME_ACTION_DONE){
                //隐藏软键盘
                InputMethodManager imm = (InputMethodManager) v
                        .getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                if (imm.isActive()) {
                    imm.hideSoftInputFromWindow(
                            v.getApplicationWindowToken(), 0);
                }
                return true;
            }
            return false;
        }
    });

相关文章

网友评论

      本文标题:Android开发点软键盘完成收起软键盘

      本文链接:https://www.haomeiwen.com/subject/vthhwrtx.html