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

时间:2014-08-06 07:12:58

标签: android keyboard

我想实现保存按钮而不是输入软键盘,并且在此按钮上有听众,我该怎么办?

input.setImeOptions(EditorInfo.IME_ACTION_DONE);

如何处理此事件?

1 个答案:

答案 0 :(得分:2)

尝试创建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;
    }
}

并设置为EditText喜欢

edit_Notes.setOnEditorActionListener(new DoneOnEditorActionListener());