From a Fragment, I am using a SearchView inside an AlertDialog and I would like the keyboard's 'Done' button to dismiss the keyboard. For some reason it is not working.
Here is my AlertDialog"
val mBuilder =
AlertDialog.Builder(context!!, Theme_DeviceDefault_Light_NoActionBar_Fullscreen)
val mView = View.inflate(activity!!, R.layout.list_search, null)
mBuilder.setView(mView)
val dialog = mBuilder.create()
val searchView = view.findViewById<SearchView>(R.id.search_view)
dialog.show()
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE)
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextChange(newText: String): Boolean {
adapterWithSearch.filter(newText)
return true
}
override fun onQueryTextSubmit(query: String): Boolean {
adapterWithSearch.filter(query)
return true
}
})
And here is my SearchView:
<SearchView
android:id="@+id/searchView"
style="@style/AppTheme.Searches"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:actionViewClass="android.support.v7.widget.SearchView"
android:iconifiedByDefault="false"
android:imeOptions="actionDone"
android:inputType="text"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true" />
I would like the keyboard to be dismissed, not the AlertDialog. Anyone has an idea of why the keyboard isn't being dismissed?