I'm trying to set a listener to EditText
when enter button will be pressed.But it didn't fire at all. I tested this on LG Nexus 4 with Android 4.2.2. setOnEditorActionListener
works on Amazon Kindle Fire with Android 2.3 and setImeActionLabel
works nowhere! I also can't set text for Enter
button.Here is code:
mEditText.setImeActionLabel("Reply", EditorInfo.IME_ACTION_UNSPECIFIED);
mEditText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
Log.d("TEST RESPONSE", "Action ID = " + actionId + "KeyEvent = " + event);
return true;
}
});
What am I doing wrong? How can I fix this?
You can use TextWatcher.
I use the following code
make sure:
inputType = "text";
imeOptions = "actionSend";
After some little more searching - this was the solution for me (works also in a fragment):
Just remove the
imeAction
Make sure that you have an IME_ACTION set in the layout file:
For a full explanation, see http://developer.android.com/guide/topics/ui/controls/text.html.
I got it, it works on Edittext in an Activity, but not in a Fragement.