CoordinatorBehaviorExample icon indicating copy to clipboard operation
CoordinatorBehaviorExample copied to clipboard

Menu onOptionsItemSelected issue

Open yuanliu666 opened this issue 7 years ago • 1 comments
trafficstars

For this example if you directly add onOptionsItemSelected it will not work. To solve this you need to add one line of code:

...
mToolbar.inflateMenu(R.menu.menu_main);
// add this line
setSupportActionBar(mToolbar);
...

And now it works! But the default title is annoying, so add another line to remove default title.

...
mToolbar.inflateMenu(R.menu.menu_main);
// add this line
setSupportActionBar(mToolbar);
setTitle("");
...

Cheers!

yuanliu666 avatar Mar 05 '18 21:03 yuanliu666

This is something you should probably be doing anyways.

drinfernoo avatar Mar 09 '18 05:03 drinfernoo