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.

Found myself in need of moving an item stored in an IList to the top of the stack. Some IList methods like RemoveAt() and Insert() would work however wouldn’t be as efficient with a large data set. Fortunately found a Stack Overflow post which would do the move in a single step. I renamed the extension to MoveToTop and here’s a quick and easy Xamarin Workbook sample.


Id: 3 Name: Third
Id: 1 Name: First
Id: 2 Name: Second

Hope someone finds this useful. Feel free to share/like etc.

Some years ago I wrote a handy library Get iOS Model that I open-sourced on Github and through the years I’ve been asked if I would ever create an Xamarin.Android version. Finally got around to it and made it available this week.

The package consists of 18,554 Android devices that support Google Play which I will update regularly.

Using the package is pretty simple:

  1. Install the nuget package dannycabrera.GetDroidModel
  2. Make a call to:

Example: Device model “SM-G960F” will return as “Galaxy S9”.

If you prefer having the manufacturer’s name returned call:

GetDroidModel.DeviceHardware.Model(defaultValue: “Unknown”, includeManufacturer: true);

Example: Device model “SM-G960F” will return as “Samsung Galaxy S9”.

Hope this is a useful library/plugin for all.

Danny Cabrera

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