I am using search view in my app to search through a list of item and run a query on a URL.
I am using the following code :
public boolean onQueryTextSubmit(String s) {
mSearchView.setQuery("", false);
mSearchView.clearFocus();
mSearchView.setIconified(true);
url+="intitle="+s+"&site=stackoverflow";
// mSearchView.setQuery("", false);
// mSearchView.clearFocus();
// mSearchView.setIconified(true);
new JSONTask().execute();
return false;
}
So I modify the URL based on the search query and run the async task to load the list of results.
This works fine the first time I search, but all subsequent searches give the same result even when the query is changed.
How do I fix this ?
Thanks !
If the variable url
is global, you should set it's value to the initial value at the end of your onQueryTextSubmit(String s)
method, because then on every next step it will concat the strings ( +=
) and will be something like this url = %your original value%intitle="s"&site=stackoverflowintitle="s"&site=stackoverflowintitle="s"&site=stackoverflow