Last active
April 19, 2018 13:18
-
-
Save dannycabrera/7cddf936b478f10ee2aa63327a298217 to your computer and use it in GitHub Desktop.
Xamarin.Android Dismiss SetSingleChoiceItems on DialogClickEventArgs handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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