I have include SearchView
in the HomeScreen
. I use SearchView
for place search. This is my screenshot of HomeScreen
:
This is my code in onCreateOptionsMenu
method:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.home, menu);
searchItem = menu.findItem(R.id.menu_item_search_places);
searchItem.setIcon(FontIconDrawable.inflate(getContext(), R.xml.ic_search));
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnSuggestionListener(this);
searchView.setOnQueryTextListener(this);
placesSearchAdapter = new PlacesSearchAdapter(this.getContext());
searchView.setSuggestionsAdapter(placesSearchAdapter);
searchView.setMaxWidth(750);
MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
corLDriveInfoContainer.setVisibility(View.GONE);
fabDrivingDirection.setVisibility(View.VISIBLE);
mapView.deleteAllAnnotationsAndCustomPOIs();
return true;
}
});
}
This is my SearchView
when I click on SearchIcon
.
This is my SearchView
result:
I have FabButton
to drive the selected position.
But, my problem is, How do go back to View C
from View D
when I press back button?
You should override
onBackPressed
method in your activity like this