Xamarin.Android Dismiss SetSingleChoiceItems on DialogClickEventArgs handler

If you are ever working on a Xamarin.Android App and need to dismiss an AlertDialog box when loading SingleChoiceItems here’s an easy way to achieve it.

In the example below we create a new DialogBuilder instance, adding a title and then loading several items as SingleChoiceItems. Then on the DialogClickEventArgs handler grab a reference to the AlertDialog var d; and simply call d.Dismiss() to dismiss dialog, removing it from the screen.

Written by

Principal Software Engineer at Command Health https://github.com/dannycabrera

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store