[英]Save button in soft keyboard instead of enter in android
我想實現保存按鈕而不是在軟鍵盤上輸入,並且要在此按鈕上監聽,我該怎么做?
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
如何處理此事件?
嘗試創建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());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.