我找到this question,然后我意识到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);
}
});
由于
答案 0 :(得分:2)
ActionMenuView有一个MenuItemClick事件,您可以使用它来代替侦听器。
amv.MenuItemClick+= delegate(object sender, ActionMenuView.MenuItemClickEventArgs e)
{
// your code for the click
};