Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannycabrera/7cddf936b478f10ee2aa63327a298217 to your computer and use it in GitHub Desktop.
Save dannycabrera/7cddf936b478f10ee2aa63327a298217 to your computer and use it in GitHub Desktop.
Xamarin.Android Dismiss SetSingleChoiceItems on DialogClickEventArgs handler
var dialogBuilder = new Android.App.AlertDialog.Builder(Context);
dialgBuilder.SetTitle("My Title");
string[] items = new string[] { "Item 1", "Item 2", "Item 3", "Item 4" };
dialogBuilder.SetSingleChoiceItems(items, 0, new EventHandler<DialogClickEventArgs>(delegate (object sender, DialogClickEventArgs e) {
// Get reference to AlertDialog
var d = (sender as Android.App.AlertDialog);
// Do something with selected index
Toast.MakeText(Context, $"SelectedItemIndex: {e.Which}", ToastLength.Short).Show();
// Dismiss Dialog
d.Dismiss();
}));
dialogBuilder.SetPositiveButton("OK", delegate{});
dialogBuilder.Show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment