I had the following code in onCreate:
commentET = (EditText) findViewById(R.id.comment);
commentET.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
Log.i("UdazzT", "enter pressed");
return true;
default:
break;
}
}
return false;
}
});
and the layout:
<EditText android:hint="@string/comment"
...
android:imeOptions="actionGo"/>
I've also tried with actionSend and actionSearch
android:imeOptions="actionGo"
correspond to theEditorInfo.IME_ACTION_GO
:I personaly use: