Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Inject a Menu #1413

Description

@KleinerHacker

If I want to use menu groups with id to change visibility of items between activity state changes I cannot use android annotations because I need the Menu instance to call method setGroupVisibile. There is a way to get the menu via android annotations like:

@EActivity
@OptionsMenu(R.menu.my_menu)
public class MyActivity extends Activity {
    @OptionMenu
    protected Menu menu;

   ....

   private void toggleState() {
      menu.setGroupVisibile(R.id.mnu_my_menu_grp_my_group1, false);
      menu.setGroupVisibile(R.id.mnu_my_menu_grp_my_group2, true);
   }
}

My current work arround is to override the onCreateOptionsMenu method:

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        this.optionsMenu = menu;
        return super.onCreateOptionsMenu(menu);
    }

Activity

  1. WonderCsabo commented on May 10, 2015

    @WonderCsabo
    Member

    So actually you want to inject the Menu with @InjectMenu (or sg) just like MenuItem with @OptionsMenuItem?

  2. KleinerHacker commented on May 10, 2015

    @KleinerHacker
    Author

    Yes, but an annotation with this functionality does not exists.

  3. WonderCsabo commented on May 10, 2015

    @WonderCsabo
    Member

    I know. 😉

    I think this should be a useful feature. @yDelouis @dodgex WDYT?

  4. changed the title [-]Support for Menu Groups[/-] [+]Inject a Menu[/+] on May 10, 2015
  5. dodgex commented on May 10, 2015

    @dodgex
    Member

    this could indeed be usefull.

  6. WonderCsabo commented on May 10, 2015

    @WonderCsabo
    Member

    Thanks!

    @KleinerHacker i am marking this as an enhancement, but this is the end of our queue now. Contributions are welcome.

  7. WonderCsabo commented on Jun 9, 2015

    @WonderCsabo
    Member

    Implemented.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions