电话是以下方法或属性之间暧昧:`Android.App.AlertDialog.Builder.SetPositiveButton [英] The call is ambiguous between the following methods or properties: `Android.App.AlertDialog.Builder.SetPositiveButton

查看:697
本文介绍了电话是以下方法或属性之间暧昧:`Android.App.AlertDialog.Builder.SetPositiveButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一刻我试图与C#Android应用程序创建一个警告对话框。不幸的是我得到这个错误:

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)

这是我的代码:

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



我在做什么错了?

What am I doing wrong?

推荐答案

您的来电 .setPositiveButton(OK,NULL)不明确,因为该方法具有2过载和您的第二个参数为空即可解释为:

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>

  • 或作为 Android.Content.IDialogInterfaceOnClickListener

  • 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)

这篇关于电话是以下方法或属性之间暧昧:`Android.App.AlertDialog.Builder.SetPositiveButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆