Toolbar.inflateMenu seems to do nothing

前端 未结 1 932
耶瑟儿~
耶瑟儿~ 2020-12-03 13:33

Im currently messing arround with the new AppCompat library bringing material design to older devices.

Setting a toolbar as actionbar works fine for me, but the tool

相关标签:
1条回答
  • 2020-12-03 13:49

    If you are calling setSupportActionBar() you don't need to use toolbar.inflateMenu() because the Toolbar is acting as your ActionBar. All menu related callbacks are via the default ones. The only time you need to call toolbar.inflateMenu() is when you are using the Toolbar as a standalone widget. In this case you will also have to handle menu item click events via

    toolbar.setOnMenuItemClickListener(
            new Toolbar.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    // Handle menu item click event
                    return true;
                }
    });
    
    0 讨论(0)
提交回复
热议问题