protected async void updateAdapter(string query)
        {
            //Tries to get suggested results, shows whatever it can get
            try
            {
                //Checks that the query is not blank, fetches suggestions using current location if so
                if (query.Length > 0)
                {
                    //Gets up to 3 suggested results
                    string[] suggestedResults = await mbi.FetchAutocompleteSuggestions(query, 3, map.MyLocation.Latitude, map.MyLocation.Longitude);

                    //Clears the adapter
                    adapter.Clear();
                    //Sets the adapter to contain the suggested results
                    adapter.AddAll(suggestedResults);
                }
                //If the query was blank, clear the adapter
                else
                {
                    adapter.Clear();
                }
                //Makes sure that the current location is always an option
                adapter.Add("Current Location");
                //If the dialog should not be shown, dismiss the dialog
                if (!showDialog)
                {
                    view.DismissDropDown();
                }
                //Notifies the adapter that the data has been changed.
                adapter.NotifyDataSetChanged();
            }
            //Always shows the drop down if the flag is set when this function is called
            finally
            {
                if (showDialog)
                {
                    view.ShowDropDown();
                }
            }
        }
示例#2
0
 protected override void PublishResults(ICharSequence constraint, FilterResults results)
 {
     adapter.NotifyDataSetChanged();
 }