0

I want to display suggestion as user types in text box same like Google.
I am using AutoCompleteTextView and I want to use Google API/ my own web service for getting suggestion.
How AutoCompleteTextView can be used with API or any other web service ?

Thanks,
Ajinkya.

Ajinkya
  • 22,324
  • 33
  • 110
  • 161

1 Answers1

2

You can use this jar to get the result in a List

 import gsearch.*;

 Client client = new Client();    
 List<Result> ajax = c.searchWeb("google ajax search");

Use this List in conjunction with the ArrayAdapter. Trigger this when new text is entered in the Edit box. Call notifydatasetchanged() every time new data is downloaded.

Reno
  • 33,594
  • 11
  • 89
  • 102
  • Thanks for the link. How can I use my web service instead of Googles ? – Ajinkya Nov 10 '11 at 09:05
  • Your web service will return a JSON or XML, parse and populate the data set associated with the Adapter. See [this for an example](http://stackoverflow.com/questions/1967814/refresh-arrayadapter-dynamically) – Reno Nov 10 '11 at 09:09
  • In the question I couldnt see the code which calls the web service. – Ajinkya Nov 10 '11 at 09:12
  • Parsing of the web-service response is something that you have to implement. You are the designer of the web-service after all. There is plenty of help regarding parsing JSON and XML on [so] – Reno Nov 10 '11 at 09:17
  • I am bit familiar with parsing XML but I am talking about calling a web service. I dont have any idea about how to call a web service in android. – Ajinkya Nov 10 '11 at 09:26
  • See [this snippet](http://www.androidsnippets.com/retrieve-json-from-a-rest-web-service) for JSON. [This for SOAP](http://stackoverflow.com/questions/297586/how-to-call-soap-web-service-with-android) .. etc – Reno Nov 10 '11 at 09:35