Search code examples
androidfocusandroid-edittext

Android: Force EditText to remove focus?


I would like to be able to remove the focus from the EditText. For example if the Keyboard appears, and the user hides it with the back button, I would like the focus and the cursor to disappear. How can it be done?


Solution

  • You can add this to onCreate and it will hide the keyboard every time the Activity starts.

    You can also programmatically change the focus to another item.

     this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);