3

Momently i'm trying to create an Alert Dialog on Android application with C#. Unfortunately I get this error:

The call is ambiguous between the following methods or properties: `Android.App.AlertDialog.Builder.SetPositiveButton(string, System.EventHandler<Android.Content.DialogClickEventArgs>)' and `Android.App.AlertDialog.Builder.SetPositiveButton(string, Android.Content.IDialogInterfaceOnClickListener)' (CS0121) (App)

This is my code:

var alert = new AlertDialog.Builder(this).SetTitle("Title").SetMessage("Message").setPositiveButton("OK", null);
alert.Show ();
return true;

What am I doing wrong?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
lukso
  • 589
  • 5
  • 13
  • 31

1 Answers1

6

your call to .setPositiveButton("OK", null) is ambiguous because the method has 2 overloads and your second parameter null can be interpreted as :

  • System.EventHandler<Android.Content.DialogClickEventArgs>
  • or as a Android.Content.IDialogInterfaceOnClickListener

if you want to invoke the second overload, try this:

.setPositiveButton("OK", (Android.Content.IDialogInterfaceOnClickListener)null)
sim1
  • 722
  • 7
  • 12