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」的函數應該是靜態的。 –