Skip to content

Menu onOptionsItemSelected issue #44

Open

Description

@yuanliu666

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!

Activity

  1. drinfernoo commented on Mar 9, 2018

    @drinfernoo

    This is something you should probably be doing anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions