简体   繁体   English

在软键盘中保存按钮,而不是在android中输入

[英]Save button in soft keyboard instead of enter in android

I want to implement save button instead of enter in soft keyboard, and listener on this button, how can i do it? 我想实现保存按钮而不是在软键盘上输入,并且要在此按钮上监听,我该怎么做?

input.setImeOptions(EditorInfo.IME_ACTION_DONE);

how to handle this event? 如何处理此事件?

Try to create DoneOnEditorActionListener and set to your EditText like 尝试创建DoneOnEditorActionListener并将其设置为您的EditText

 class DoneOnEditorActionListener implements OnEditorActionListener {

    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        // TODO Auto-generated method stub
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            return true;
        }
        return false;
    }
}

and set to your EditText like 并设置为您的EditText

edit_Notes.setOnEditorActionListener(new DoneOnEditorActionListener());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM