Reputation: 1179
When you click the back button, the keyboard hides itself but the focus on the edittext remains. How can I reproduce this behaviour?
Upvotes: 0
Views: 161
Reputation: 763
You can use this code to hide the keyboard:
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
);
Or this one :
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
If the EditText loses the focus, simple write a simple command
editText.requestFocus();
Upvotes: 1