0

I can't find anything about the thing i need. When the user is typing his stuff in the editText he has to press a button to perform a task. What i want to do is that when he presses Enter on the keyboard, it would be equivalent to the button task.

ss

Dawid
  • 585
  • 5
  • 26

1 Answers1

0

You need to use and EditiorActionListener

editBox.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
    //button action}
    return false;
    }
});

Anshul
  • 387
  • 3
  • 15