我有一个的PopupMenu
,我知道通常的方式关联一个菜单,它是使用 popup.getMenuInflater()。膨胀(R .menu.my_menu,popup.getMenu());
或什么之类的。我的问题是,我有我想要的菜单项的数组,我需要能够以编程方式更改他们的Java。我怎样才能做到这一点?
I have a PopupMenu
and I know the usual way to associate a menu to it is to use popup.getMenuInflater().inflate(R.menu.my_menu, popup.getMenu());
or something of the like. My problem is, I have an array of items that I want in the menu and I need to be able to change them programmatically in Java. How can I do this?
感谢您!
刚琢磨出来;任何人谁跑入你只是做同样的问题:
Just figured it out; for anyone who runs into this same problem you just do:
popup.getMenu().add(groupId, itemId, order, title);
对于每个菜单项
要添加。