如何在 Xamarin 上使用 SetOnMenuItemClickListener?
How to use SetOnMenuItemClickListener on Xamarin?
我找到了 ,然后我意识到 Java 代码在 C# 上不工作,我不知道如何实现这段代码:
amvMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onOptionsItemSelected(menuItem);
}
});
它导致错误:
Cannot create an instance of the abstract class or interface 'ActionMenuView.IOnMenuItemClickListener
到目前为止我的代码:
tbchild.SetOnMenuItemClickListener(new ActionMenuView.IOnMenuItemClickListener() {
public bool onMenuItemClick(IMenuItem menuItem)
{
return OnOptionsItemSelected(menuItem);
}
});
谢谢
ActionMenuView 有一个 MenuItemClick 事件,您可以使用它代替侦听器。
amv.MenuItemClick+= delegate(object sender, ActionMenuView.MenuItemClickEventArgs e)
{
// your code for the click
};
我找到了
amvMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onOptionsItemSelected(menuItem);
}
});
它导致错误:
Cannot create an instance of the abstract class or interface 'ActionMenuView.IOnMenuItemClickListener
到目前为止我的代码:
tbchild.SetOnMenuItemClickListener(new ActionMenuView.IOnMenuItemClickListener() {
public bool onMenuItemClick(IMenuItem menuItem)
{
return OnOptionsItemSelected(menuItem);
}
});
谢谢
ActionMenuView 有一个 MenuItemClick 事件,您可以使用它代替侦听器。
amv.MenuItemClick+= delegate(object sender, ActionMenuView.MenuItemClickEventArgs e)
{
// your code for the click
};