3
I’m trying to capture the enter key to jump from one EditText
to another. The problem is that the method onKey()
is not called when I press a key, for it to run I need to hold the key for a while.
My code:
this.mHolder.editLargura.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER)
{
mHolder.editComprimento.requestFocus();
}
return false;
}
});
What can I do for him to be triggered without me having to hold a key?
The documentation of
onKeyListener
It says it’s only triggered for sure by physical keyboards. Software keyboards usually do not activate this Switch, except in some special cases. I don’t know what your case is, but you will probably need another type of Systener, like this one: https://developer.android.com/reference/android/inputmethodservice/KeyboardView.OnKeyboardActionListener.html– Lucas Martins
Thanks, that already helps
– Jonathan Emanuel