我的动作栏中有一个图标如何设置一个onclicklistener到我迄今为止所拥有的项目,并尝试添加和意图,但它仍然无法正常工作
@Override
public boolean onOptionsItemSelected(MenuItem item){
super.onOptionsItemSelected(item);
if(item.getItemId() == R.id.item3) {
Intent homeIntent = new Intent(null, HomeMainActivity.class);
startActivity(homeIntent);
return true;
}
return super.onOptionsItemSelected(item);
}
答案 0 :(得分:-1)
在If条件
之前删除行super.onOptionsItemSelected(item);
@Override
public boolean onOptionsItemSelected(MenuItem item){
if(item.getItemId() == R.id.item3) {
Intent homeIntent = new Intent(null, HomeMainActivity.class);
startActivity(homeIntent);
return true;
}
return super.onOptionsItemSelected(item);
}