从标题栏到onCreate |的命令Android的

时间:2017-04-10 10:40:24

标签: android titlebar

有人知道如何将标题栏中的项目代码放入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);
}

感谢您的帮助!

0 个答案:

没有答案