There is one in my application EditText. I called the keyboard display in my activity for this EditText. The keyboard shows and works fine.
Now, at present, I have to press the button twice two times, one to hide the keyboard and the other to perform some task (for example, saving data to the database). I do not want to press the return button twice.
please help me or suggestion
here are some of onBackPressed()
@Override
public void onBackPressed() {
super.onBackPressed();
hideKeypad();
}
the code hideKeypad()
private void hideKeypad() {
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext1.getWindowToken(), 0);
}
source
share