Example #1
0
        private async void AutoComplete()
        {
            OnPrepareOptionsMenu(actionBarMenu);
            actionBarMenu.FindItem(Resource.Id.action_add_to_fav).SetVisible(false);

            try
            {
                MapFragment mapFragment = FragmentManager.FindFragmentByTag <MapFragment>("MAP_FRAGMENT");

                // just dont autocomplete
                if (mapFragment.MyLocation == null)
                {
                    return;
                }

                List <Prediction> predictions = await PlacesService.GetSearchQueryPredictions(
                    searchTextView.Text, mapFragment.MyLocation);

                AWidget.ArrayAdapter adapter = new AWidget.ArrayAdapter <string>(
                    this, Android.Resource.Layout.SimpleDropDownItem1Line, predictions.Select(x => x.description).ToArray());

                searchTextView.Adapter = adapter;
                adapter.NotifyDataSetChanged();
            }
            catch (ApiCallException)
            {
            }
            catch (QueryAutoCompleteException)
            {
            }
        }