Tôi chỉ muốn nắm bắt sự kiện khi người dùng nhấn enter trên editText.OnEditorActionListener không hoạt động
Tôi không nhận được thông báo Toast chứ không phải là "Enter pressed" chứ không phải là "Some pressed pressed!" hoặc.
Tôi đang làm gì sai?
myEditText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Toast.makeText(getApplicationContext(), "Some key pressed!", Toast.LENGTH_LONG).show();
if (event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
Toast.makeText(getApplicationContext(), "Enter pressed", Toast.LENGTH_LONG).show();
return true;
}
return false;
}
});
E D I T:
Vâng nó là làm việc trên Android 2.3.3 và không làm việc trên 4.1.2 Bất kỳ ý tưởng làm thế nào tôi có thể làm cho công việc này trên bất kỳ thiết bị Android?
bạn có thể sử dụng TextWatcher cho bất kỳ sự kiện nào liên quan đến Edittext –