There is a fragment with a list and SearchView. Filtering works, everything is in order. Problem: when moving to another fragment and then back (BackStack), the previous query remains in SearchView. But the list itself was not filtered, as there was no input event. I need to either clear the list or make the query string apply. For cleaning in onViewCreated I tried to do svName.setQuery ("", false); Does not work. Tell me how to do it.
The code below is called in onViewCreated:
// Фильтрация списка svName = (SearchView) view.findViewById(R.id.svName); svName.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { // String text = edtName.getText().toString().toLowerCase(Locale.getDefault()); Log.d(myLog, "Фильтр - " + newText); myAdapter.getFilter().filter(newText); return false; } });