I have a problem with the Enter key in android, I have an edittext where I enter a value and then when I click on Enter, I want it to make something. My problem is that I have to press Enter twice to get the desired results.
editText1.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER)) {
// Perform action on key press
mWebView.loadUrl(editText1.getText().toString());
mWebView.requestFocus();
return true;
}
return false;
}
});