//voice to text. protected override void OnActivityResult(int requestCode, Result resultVal, Intent data) { string[] roomsArray = new string[Rooms.rooms.Length]; Rooms.rooms.CopyTo(roomsArray, 0); if (requestCode == VOICE) { if (resultVal == Result.Ok) { searchACTextView.Text = ""; var matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults); if (matches.Count != 0) { string textInput = searchACTextView.Text + matches[0]; // limit the output to 30 characters if (textInput.Length >= 10) { textInput = textInput.Substring(0, 10); textInput = textInput.ToUpper(); for (int i = 0; i < roomsArray.Length; i++) { if (textInput == roomsArray[i]) { searchACTextView.Text = textInput; strartingNavAudio.Start(); searchACTextView.DismissDropDown(); return; } } tryAgainAudio.Start(); } else if (textInput.Length == 5) { for (int i = 0; i < roomsArray.Length; i++) { if (textInput == roomsArray[i].Substring(5, 5)) { searchACTextView.Text = roomsArray[i]; strartingNavAudio.Start(); searchACTextView.DismissDropDown(); return; } } tryAgainAudio.Start(); } else { tryAgainAudio.Start(); } } } } base.OnActivityResult(requestCode, resultVal, data); }
protected void configureActv(AutoCompleteTextView actv, AutoCompleteTextView actvOther, FrameLayout frame, Button clear, Button navButton) { //Initializes the actv suggestions adapter ArrayAdapterNoFilter adapter = new ArrayAdapterNoFilter(this, Android.Resource.Layout.SimpleDropDownItem1Line); //Initializes the suggestions updater for the adapter AutocompleteSuggestionUpdater suggestor = new AutocompleteSuggestionUpdater(actv, adapter, map, mbi); //Sets the adapter of the actv actv.Adapter = adapter; //Sets the updater to update the suggestions when the text changes actv.AddTextChangedListener(suggestor); InputMethodManager imm = (InputMethodManager)GetSystemService(Activity.InputMethodService); //Sets delegates for handling the opacity of the navigation button actv.AfterTextChanged += delegate { //Updates the color of the actv based on whether the address is valid makeActvTurnGreenWhenAddressesAreValid(actv, frame); }; //Sets delegate for when the enter button is pushed on the keyboard actv.EditorAction += delegate { //Unfocuses from the actv, closes the dropdown, and hides the keyboard. actv.ClearFocus(); actv.DismissDropDown(); imm.HideSoftInputFromWindow(actv.WindowToken, 0); }; //Sets delegate for if the actv is clicked actv.ItemClick += delegate { //Closes the dropdown menu, turns off the suggestor, updates the route button's opacity, and hides the keyboard actv.DismissDropDown(); suggestor.showDialog = false; Tools.makeRouteButtonOpaqueIfBothAddressesAreValid(actv.Text, actvOther.Text, navButton, mbi); imm.HideSoftInputFromWindow(actv.WindowToken, 0); }; //Sets delegate for if the actv changes color frame.LayoutChange += delegate { //Updates the route button's opacity Tools.makeRouteButtonOpaqueIfBothAddressesAreValid(actv.Text, actvOther.Text, navButton, mbi); }; //Sets delegate for if the clear button has been pressed clear.Click += delegate { //Closes the dropdown menu, updates the route button's opacity, //gets the suggestor ready to start making suggestions when the user types again, and clears the text in the box actv.DismissDropDown(); Tools.makeRouteButtonOpaqueIfBothAddressesAreValid(actv.Text, actvOther.Text, navButton, mbi); suggestor.showDialog = true; actv.Text = ""; }; }
private void AgencyDropDown_Click(object sender, EventArgs e) { if (showAgencyDropdown) { AgencyTextView.ShowDropDown(); showAgencyDropdown = false; } else { AgencyTextView.DismissDropDown(); showAgencyDropdown = true; } }
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(); } } }
internal static void Clear(this AutoCompleteTextView autoCompleteTextView) { autoCompleteTextView.Adapter = null; autoCompleteTextView.DismissDropDown(); autoCompleteTextView.Error = null; }