0

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

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
lina saeed
  • 81
  • 1
  • 8

1 Answers1

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