I have a searchView which looks like this:
private void setupSearchView() {
mSearchView = (SearchView) getActivity().findViewById(
R.id.search_vi
I must suggest to use setOnSearchClickListener
listner to detect SearchView
click as According to Android docs :
setOnSearchClickListener
void setOnSearchClickListener (View.OnClickListener listener)
Sets a listener to inform when the search button is pressed.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.orders_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchView != null) {
searchView = (SearchView) searchItem.getActionView();
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//perform your click operation here
}
});
return true;
}