There is this widget for the ActionBar which called \'SearchView\'. When it\'s not in use, it looks like this:
Expanding the answer of Matthias Robberts:
I wanted a list fragment to keep it's search value and set it after user returns from other fragment.
if (myViewModel.filterTextSaved.isNotEmpty()) { // Kotlin, storing state in ViewModel
searchItem.expandActionView() // needs to come first, otherwise empty text
theTextArea.setText(courseViewModel.filterTextOnClick)
}
and for the menu I keep always|collapseActionView, otherwise it stays open when user deletes the text.