Segure a tecla “Enter” no Jelly Bean
Estou fazendo um pedido, neste aplicativo tenho edição de texto. Quero que quando o usuário escreva algum texto no final do texto de edição e pressione o botão Enter, quero que chame algum comando. Isto é o que eu tenho feito. Isso é trabalho no ICS, mas quando eu tento em outro dispositivo (Jelly Bean), ele não funciona.
inputViaTextChatbot.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
// hide the keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
// process
getThis = inputViaTextChatbot.getText().toString();
if (getThis!=null && getThis.length()>1) {
try {
Log.v("Got This: ", getThis);
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
inputViaTextChatbot.setText("");
}
}
return false;
}
});
alguém pode me ajudar a fazer isso?