I currently have a SearchView
in the action bar of my app. When I click the search icon, the SearchView
expands and the keyboard pops up as expecte
There is a simple way to do this:
@Override
public void onBackPressed() {
if (!searchView.isIconified()) {
searchView.onActionViewCollapsed();
} else {
super.onBackPressed();
}
}
or use:
myToolBar.collapseActionView();
This will make the searchView to collapse before you press the back then the back action will be called.
Both solutions will work.