I am using PlaceAutocompleteApi
from Play Services, what I want to do is restrict auto-complete to specific country & city only. Eg. All cities from lets say In
Here's a workaround (hack if you will) that I used. It utilizes (exploits) the fact that when converted to string, each response item is a comma separated string. Do the following steps before returning the result to getFilter()
.
ArrayList
, call it returnedResults
.returnedResults
and in each iteration get each prediction into a string array using returnedResults.get(i).getFullText(xxx).toString().split(",")
.ArrayList
variable, let's call it myResult
.myResult
.The reason for using separate variables is because you might not be able to manipulate the original response list so easily. This approach works like a charm!
Hope this helps.