且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Android中将菜单设置为工具栏

更新时间:2022-12-19 09:10:17

只需在MainPage.java

just override onCreateOptionsMenu like this in your MainPage.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main_menu, menu);
    return true;
}