How can i Use SearchView to perform an online search within my App, and presenting the result in a ListView using such query: https://www.googleapis.com/books/v1/volumes?q=android&maxResults=10
Asked
Active
Viewed 64 times
1 Answers
0
Use SearchView inside xml then get the reference to that object and set a listener and do network call after receiving the query.
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String txt) {
return false;
}
@Override
public boolean onQueryTextChange(String txt) {
//Do network call from here.
doSearch(txt);
return false;
}
});
void doSearch(String query){
String url = "https://www.googleapis.com/books/v1/volumes?q="+query+"&maxResults=10";
....
}

webianks
- 125
- 3
- 10
-
how can i use this with AsynTasck class? – lina saeed Oct 07 '19 at 10:58
-
https://stackoverflow.com/questions/14250989/how-to-use-asynctask-correctly-in-android – webianks Oct 07 '19 at 11:22