Code example for SearchView

Methods: setOnQueryTextListener

0
    private static final String TAG = "SVS.Honeycomb";
 
    @Override 
    public void setup(MenuItem searchMenuItem, final OnFilterTextListener onFilterTextListener) {
        final SearchView searchView = (SearchView) searchMenuItem.getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override 
            public boolean onQueryTextChange(String newQueryText) {
                Log.d(TAG, "onQueryTextChange : "+newQueryText);
                onFilterTextListener.onFilterTextChange(newQueryText);
                return true; 
            } 
 
            @Override 
            public boolean onQueryTextSubmit(String query) {
                Log.d(TAG, "onQueryTextSubmit : "+query);
                onFilterTextListener.onFilterTextSubmit(query);
                return true; 
            } 
        }); 
    }