Yes, there is. The following code retrieves places from the Google Places API and populates the an ArrayAdapter, which changes as the text in the AutocompleteTextView changes.
// declare this variable globally in your activity so that it can be
//referenced and updated in the inner class (public void onResult(...))
private ArrayAdapter<String> adapter;
AutoCompleteTextView locationText = (AutoCompleteTextView) findViewById(R.id.location_text);
adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_dropdown_item_1line);
locationText.setAdapter(adapter);
locationText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String query = s.toString();
//mMap is a GoogleMap object. Alternatively, you can initialize a
//LatLngBounds object directly through its constructor
LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds;
AutocompleteFilter filter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_NONE)
.build();
PendingResult<AutocompletePredictionBuffer> autocompleteResult =
Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, query,
bounds, filter);
autocompleteResult.setResultCallback(new ResultCallback<AutocompletePredictionBuffer>() {
@Override
public void onResult(@NonNull AutocompletePredictionBuffer autocompletePredictions) {
for (int i = 0; i < autocompletePredictions.getCount(); i++) {
adapter.add(autocompletePredictions.get(0).getFullText(null).toString());
}
autocompletePredictions.release();
adapter.notifyDataSetChanged();
}
});
}
Below is the XML code for the AutocompleteTextView:
<AutoCompleteTextView
android:id="@+id/location_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="4"
android:hint="Search location..." />