The app I am currently writing deals with places. The main method to create a place is to enter an address. Providing a convenient way to do
Try to change this part of the code:
if ( filterResults.count > 0) {
lastSuggested = (ArrayList<Address>) filterResults.values;
}
lastInput = constraint.toString();
into this:
if ( filterResults.count > 0) {
lastSuggested = (ArrayList<Address>) filterResults.values;
lastInput = constraint.toString();
}
I think your problem is you are setting lastSuggested to suggested (via filterResults.values) and then, in the next pass, you are updating suggested --> lastSuggested will be set to the same value as suggested as Java passes variables by reference unless primitives.
So, instead of
if ( filterResults.count > 0) { lastSuggested = (ArrayList) filterResults.values; }
You should try
if ( filterResults.count > 0) {
lastSuggested.clear();
ArrayList<Address> tempList = (ArrayList<Address>) filterResults.values;
int i = 0;
while (i < tempList.size()){
lastSuggested.add(tempList.get(i));
i += 1;
}
}
The Geocoder api is not designed to give suggestions on partial strings like "10 rue Guy Ro" . You can try this in Google maps, enter "10 rue Guy Ro" and leave a space. You will not get any suggestions(Google maps is using Geocoder) but when you remove the space you will get suggestions on the partial string (Google Maps is using private API). You can use the Geocoder api the same way Google maps use, fetch the suggestion only after the user input space in the string he is typing.