I used below code for my edit text so that when I press enter it does not go to new line and works like pressing button but it does not work, what's the problem?
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int keyCode,
KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_ENTER:
search();
return true;
default:
break;
}
}
return false;
}
});