Reputation: 133
In the Android Documentation, in topic 'Adding Custom Suggestions' for Search feature, it says that:
When the user starts typing into the search dialog or search widget, the system queries your content provider for suggestions by calling
query()
each time a letter is typed.
Also, in the documentation on SearchView.OnQueryTextListener
interface (which is supposed to provide Callbacks for changes to the query text), the method onQueryTextChange (String newText)
is
Called when the query text is changed by the user.
I am trying to implement SearchView.OnQueryTextListener
to make sure that the Loader is restarted in the call to onQueryTextChange (String newText)
to deal with the "next" query because Android does not execute the query again when the query-text changes after first search(i.e. once a search has already been performed once).
My question is: If both Custom Search suggestions and SearchView.OnQueryTextListener
interface have been implemented, then, which of these two methods query()
(called by the Android system) and onQueryTextChange (String newText)
(callback method) is called when the query text changes in SearchView widget?
Upvotes: 1
Views: 1183
Reputation: 2876
@Override
public boolean onQueryTextChange(String query) {
return false;
}
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
Note: Your activity should implement SearchView.OnQueryTextListener
To answer to your question, onQueryTextChange()
is called when the user type or delete a letter and onQueryTextSubmit()
it's called when the user is pressing the done button on keyboard. You can easily check this by adding some logcat
.
Upvotes: 2