luk*_*kso 3 c# android android-alertdialog xamarin
我正在尝试使用C#在Android应用程序上创建警报对话框.不幸的是我收到此错误:
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)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
var alert = new AlertDialog.Builder(this).SetTitle("Title").SetMessage("Message").setPositiveButton("OK", null);
alert.Show ();
return true;
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
你的调用.setPositiveButton("OK", null)是不明确的,因为该方法有2个重载,你的第二个参数null可以解释为:
System.EventHandler<Android.Content.DialogClickEventArgs> Android.Content.IDialogInterfaceOnClickListener如果你想调用第二个重载,试试这个:
.setPositiveButton("OK", (Android.Content.IDialogInterfaceOnClickListener)null)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1179 次 |
| 最近记录: |