I want to dismiss the keyboard from the SearchView whenever the user presses the return key on the keyboard.
country_search.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
country_search.clearFocus()
return true
}
This code (onQueryTextSubmit) only gets called if something was put into the SearchView and keyboard's enter was pressed. It doesn't work if the SearchView was empty.
How can I dismiss the keyboard when query is empty and the user presses the keyboard enter key?