我正在为 Android 使用 MonoDevelop,并且想要实现一个消息框。
我目前正在 MapsAndLocationDemo 中尝试此代码。
这是我的代码:
public void createMessageBox (string stringQuestion)
{
var builder = new AlertDialog.Builder(this);
builder.SetTitle ("Test");
builder.SetIcon (Resource.Drawable.Icon);
builder.SetMessage (stringQuestion);
builder.SetPositiveButton ("Yes", (sender, e) => {
Toast.MakeText (this, "You clicked positive button", ToastLength.Short).Show ();
});
builder.SetNegativeButton ("No", (sender, e) => {
Toast.MakeText (this, "You clicked negative button", ToastLength.Short).Show ();
});
builder.SetNeutralButton ("Maybe", (sender, e) => {
Toast.MakeText(this, "You clicked neutral button", ToastLength.Short).Show ();
});
var dialog = builder.Create ();
dialog.Show ();
}
当从主“OnCreate”函数调用时,此代码工作正常。但是,我想从基本“ItemizedOverlay”的“Overlay”中调用此代码。
我收到以下错误:
无法通过嵌套类型“MapsAndLocationDemo.MapWithOverlayActivity.MapItemizedOverlay”访问外部类型“MapsAndLocationDemo.MapWithOverlayActivity”的非静态成员
我怎样才能让它工作?还是有更好的方法来显示消息框?
谢谢