0
我正在使用MonoDevelop for Android,并且想要实现一个消息框。显示一个消息框错误
我目前正在验证码出来的MapsAndLocationDemo。
这里是我的代码:从主“的OnCreate”函数调用时
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();
}
此代码工作正常。不过,我想从基于'ItemizedOverlay'的'Overlay'调用此代码。
我收到以下错误:
Cannot access a non-static member of outer type 'MapsAndLocationDemo.MapWithOverlayActivity' via nested type 'MapsAndLocationDemo.MapWithOverlayActivity.MapItemizedOverlay'
我怎么能请得到这个工作?还是有更好的方法来显示一个消息框?
谢谢
您发布了错误代码。名为“createMessageBox”的函数应该是静态的。 –