EditText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(URLText.getWindowToken(), 0);
EditText.setFocusable(false);
EditText.setFocusableInTouchMode(true);
return true;
} else {
return false;
}
}
});
Use the below code to remove the focus from the EditText
editText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(URLText.getWindowToken(), 0);
editText.setFocusable(false);
editText.setFocusableInTouchMode(true);
return true;
} else {
return false;
}
}
});