Example usage for android.widget SearchView onActionViewCollapsed

List of usage examples for android.widget SearchView onActionViewCollapsed

Introduction

In this page you can find the example usage for android.widget SearchView onActionViewCollapsed.

Prototype

@Override
public void onActionViewCollapsed() 

Source Link

Usage

From source file:org.que.activities.MainNavigationActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (menu != null) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main, menu);

        final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            public boolean onQueryTextSubmit(String query) {
                Toast.makeText(MainNavigationActivity.this, "Submitted: " + query, Toast.LENGTH_LONG).show();
                searchView.onActionViewCollapsed(); //close search view
                startSearch(query);/* w w w .  j ava2  s.co m*/
                return true;
            }

            public boolean onQueryTextChange(String arg0) {
                return true;
            }
        });
    }
    return super.onCreateOptionsMenu(menu);
}