有人知道如何将标题栏中的项目代码放入onCreate吗?
代码依旧如此:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout1);
// Here the code of the item should be
}
// But it's here:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main3, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.item1) {
// Command
return true;
}
return super.onOptionsItemSelected(item);
}
感谢您的帮助!