tags:

views:

630

answers:

1

I am wondering if there is a way to handle the user pressing "Enter" while typing in an EditText, something like the onSubmit HTML event.

Also wondering if there is a way to manipulate the virtual keyboard in such a way that the "Done" button is labeled something else (for example "Go") and performs a certain action when clicked (again, like onSubmit).

+1  A: 

I am wondering if there is a way to handle the user pressing "Enter" while typing in an EditText, something like the onSubmit HTML event.

Yes.

Also wondering if there is a way to manipulate the virtual keyboard in such a way that the "Done" button is labeled something else (for example "Go") and performs a certain action when clicked (again, like onSubmit).

Also yes.

You will want to look at the android:imeActionId and android:imeOptions attributes, plus the setOnEditorActionListener() method, all on TextView.

CommonsWare
(P.S. EditText extends TextView, thus why the properties you should look at are on TextView - when I first read that last sentence I did a double-take :) )
Ricket
Yeah, I'm not sure why so many things that would seem specific to editing are on `TextView` and not `EditText`. My guess is that either there are other field-like classes in use, or they reserve the right for those sorts of things.
CommonsWare