如何实现onMenuItemClickListener?
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.gameoptions,menu); menu.findItem(R.id.menu_item).setIntent(new Intent(this,QMenuActivity.class)); menu.findItem(R.id.back_item).setOnMenuItemClickListener; return true; }
@R_404_323@
我假设您要在活动中访问非静态函数.如果您没有太多信息,请尝试以下内容:
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.back_item); item.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { YourActivity.this.someFunctionInYourActivity(); return true; } }); return true; }