I'm trying to submit a SearchView
that I have in my Toolbar
from a click of a Button
that I created in my layout.
This is the relevant code in my search activity:
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
....
@Override
public boolean onQueryTextSubmit(String query) {
makeQuery(query);
return true;
}
});
searchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// searchView submit??
}
});
Is there any method like searchView.onSubmit()
searchView.onQuerySubmit();
?
You can do this
searchView.setQuery(searchView.getQuery(), true);
Well, try to use SearchView#setQuery(CharSequence query, boolean submit)
. This will submit your request if true
. If false
only query data will be changed.
Hope, it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With