我想实现保存按钮而不是输入软键盘,并且在此按钮上有听众,我该怎么办?
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
如何处理此事件?
答案 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());