private void FromButton_Click(object sender, EventArgs e) { PopupMenu menu = new PopupMenu(this, sender as View); menu.MenuItemClick += (s, a) => { if (a.Item.ItemId == 0) { UpdateAutoFrom(); } else if (a.Item.ItemId == 1) { fromTextView.RequestFocus(); fromTextView.ShowDropDown(); fromTextView.SelectAll(); fromTextView.PostDelayed(() => { InputMethodManager inputMethodManager = GetSystemService(Context.InputMethodService) as InputMethodManager; inputMethodManager.ShowSoftInput(fromTextView, ShowFlags.Forced); }, 250); } else { Stop stop = TramUrWayApplication.GetStop(a.Item.ItemId); fromTextView.Text = stop.Name; } }; // Auto: based on current location and favorites if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == Permission.Granted) { menu.Menu.Add(1, 0, 1, "Automatique").SetIcon(Resource.Drawable.ic_place); } // Favorite stops foreach (Stop stop in TramUrWayApplication.Config.FavoriteStops.GroupBy(s => s.Name).Select(g => g.First())) { menu.Menu.Add(1, stop.Id, 2, stop.Name); } // Other: focus the search box and trigger autocomplete menu.Menu.Add(1, 1, 3, "Autre ..."); menu.Show(); }