Some fixes

This commit is contained in:
Thomas 2020-12-07 15:48:20 +01:00
parent 891198b71f
commit 8209559012
1 changed files with 8 additions and 0 deletions

View File

@ -29,6 +29,7 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
@ -187,6 +188,13 @@ public class MainActivity extends AppCompatActivity {
searchView.setQuery(previousQuery, false); searchView.setQuery(previousQuery, false);
} }
}); });
ImageView searchClose = searchView.findViewById(androidx.appcompat.R.id.search_close_btn);
if (searchClose != null) {
searchClose.setOnClickListener(v -> {
previousQuery = "";
searchView.setQuery("", true);
});
}
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {