我正在尝试遵循代码
@Override
public boolean onOptionsItemSelected(MenuItem item){
// same as using a normal menu
switch(item.getItemId()) {
case R.id.refresh_acti:
MenuItem it = (MenuItem) findViewById(R.id.refresh_acti);
it.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
// TODO Auto-generated method stub
return false;
}
});
// makeToast("Refreshing...");
break;
case R.id.setting_lay:
makeToast("Saving...");
break;
}
return true;
}
但...
it.setonmenuitemclicklistner
给出以下错误。方法
setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener)
在类型
MenuItem
不适用于参数(new OnMenuItemClickListener(){})
最佳答案
您是否尝试过:
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case id_1:
Log.d("Log","ID 1 PRESSED");
return true;
default:
return super.onOptionsItemSelected(item);
}
}