I have a need to check for the enter key to start a search routine. All works except some keyboards seem to have a SEND button instead of the ENTER button. When this is pressed the code dumps. I have a small sample below. Any ideas?
tx1.setOnEditorActionListener (new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
System.out.println("Key: " + event.getKeyCode()); //BLOWS UP HERE
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
// ...
}
}
}
}
I believe that event is null in this case. for detecting the send action on the softkeyboard your onEditorActionListener should actually just do this.