Reset cursor query when closing search view #386

Without focus the search result get erased.
This commit is contained in:
Daniel Hammann 2014-03-10 20:58:15 +01:00
parent da83c8ff60
commit 6fab8a126a

View File

@ -367,6 +367,16 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
// Execute this when searching // Execute this when searching
mSearchView.setOnQueryTextListener(this); mSearchView.setOnQueryTextListener(this);
//Erase search result without focus
mSearchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
mCurQuery = null;
getLoaderManager().restartLoader(0, null, KeyListPublicFragment.this);
}
}
});
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
} }