Forum Xamarin.Android

Dynamic PopupMenu

Is there a way to create the items in a PopupMenu dynamically? That is to say rather then using a layout file create the items in the menu on the fly?

Thanks for any help!


  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    Yes you can dynamically build your menu.

    On way is using the OnPrepareOptionsMenu method. Another way is using the OnCreateOptionsMenu method and setting up your menu by code. Something like this should work.

        public override bool OnCreateOptionsMenu(IMenu menu)
            menu.Add("My menu");
            return true;
  • bpokerbpoker USMember

    Thank you!

Sign In or Register to comment.