Select to view content in your preferred language

auto complete text prompt in geocoding

2527
2
12-19-2013 07:15 PM
NigelDsouza
Frequent Contributor
Hi,
I am using the Geocoding android sample I want to implement an auto complete text prompt when the user enters an address.
This is possible in flex as there a geocoder component that has an auto completetext property.
I want to repelicate the same in android however there in no such component available.
How do I go about it?
Regards,
Nigel.
0 Kudos
2 Replies
JasonKnisley
Deactivated User
In Android you can do this by changing the EditText to an AutoCompleteTextView in your xml layout, and then setting an adapter on it in your activity. Something similar to this (I'm typing the code directly into this window, so please forgive any syntax errors)...
String[] myAddresses = new String[] { ... };

ArrayAdapter<String> addressAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, myAddresses);
AutoCompleteTextView addressTextView = (AutoCompleteTextView) findViewById(R.id.addressText);
addressTextView.setAdapter(addressAdapter);


In reality you probably want to read your array of addresses from a file or other external source rather than hard code them, but you get the idea.
0 Kudos
NigelDsouza
Frequent Contributor
Hi knisleyj,
I have done the same thing that you have posted.
I get the addresses and populate the array on result of a a geocode task. But only when I type in a string will I get the geocode task result.
The problem is how do I retrieve the address and populate the array when the activity is created?
Something like getting addresses and populating the array without running a geocode task.
Have a look at this sample..

https://developers.arcgis.com/en/flex/sample-code/geocoder.htm
thanks,
regards,
Nigel.
0 Kudos