本文整理汇总了C#中IMenu.AddSubMenu方法的典型用法代码示例。如果您正苦于以下问题:C# IMenu.AddSubMenu方法的具体用法?C# IMenu.AddSubMenu怎么用?C# IMenu.AddSubMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMenu
的用法示例。
在下文中一共展示了IMenu.AddSubMenu方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreateOptionsMenu
public override bool OnCreateOptionsMenu (IMenu menu)
{
ISubMenu sub = menu.AddSubMenu ("Evolve");
// group id, , order, text
sub.Add (0, 1, 1, "What's On");
sub.Add (0, 2, 2, "Speakers");
sub.Add (0, 3, 3, "Sessions");
sub.Item.SetShowAsAction (ShowAsAction.Always | ShowAsAction.WithText);
return true;
}
示例2: OnCreateOptionsMenu
public override bool OnCreateOptionsMenu (IMenu menu)
{
var subMenu1 = menu.AddSubMenu ("Action Item");
subMenu1.Add ("Sample");
subMenu1.Add ("Menu");
subMenu1.Add ("Items");
var subMenu1Item = subMenu1.Item;
subMenu1Item.SetIcon (Resource.Drawable.ic_title_share_default);
subMenu1Item.SetShowAsAction (MenuItem.ShowAsActionAlways | MenuItem.ShowAsActionWithText);
var subMenu2 = menu.AddSubMenu ("Overflow Item");
subMenu2.Add ("These");
subMenu2.Add ("Are");
subMenu2.Add ("Sample");
subMenu2.Add ("Items");
var subMenu2Item = subMenu2.Item;
subMenu2Item.SetIcon (Resource.Drawable.ic_compose);
return base.OnCreateOptionsMenu (menu);
}
示例3: OnCreateOptionsMenu
public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
{
// Put overlay items first
_mapView.OverlayManager.OnCreateOptionsMenu(menu, MenuLastId, _mapView);
// Put samples next
var samplesSubMenu = menu.AddSubMenu(0, MenuSamples, Menu.None, Resource.String.samples)
.SetIcon(Android.Resource.Drawable.IcMenuGallery);
var sampleFactory = SampleFactory.GetInstance();
for (var a = 0; a < sampleFactory.Count(); a++)
{
var f = sampleFactory.GetSample(a);
samplesSubMenu.Add(f.GetSampleTitle()).SetOnMenuItemClickListener(new StartSampleFragment(this, f));
}
// Put "About" menu item last
menu.Add(0, MenuAbout, (int) MenuCategory.Secondary, Resource.String.about)
.SetIcon(Android.Resource.Drawable.IcMenuInfoDetails);
base.OnCreateOptionsMenu(menu, inflater);
}
示例4: ApplyInternal
private void ApplyInternal(IMenu menu, Context context, int id, int order, object dataContext, bool useContext)
{
PlatformExtensions.ValidateTemplate(ItemsSource, Items);
bool isSubMenu = !string.IsNullOrEmpty(ItemsSource) || (Items != null && Items.Count > 0);
XmlPropertySetter<MenuItemTemplate, IMenuItem> setter;
int groupId;
int.TryParse(Group, out groupId);
if (isSubMenu)
{
ISubMenu subMenu = menu.AddSubMenu(groupId, id, order, string.Empty);
setter = new XmlPropertySetter<MenuItemTemplate, IMenuItem>(subMenu.Item, context, new BindingSet());
subMenu.SetBindingMemberValue(AttachedMembers.Object.Parent, menu);
subMenu.Item.SetBindingMemberValue(AttachedMembers.Object.Parent, subMenu);
SetDataContext(subMenu, setter.BindingSet, dataContext, useContext);
ApplySelf(subMenu.Item, setter);
if (string.IsNullOrEmpty(ItemsSource))
{
for (int index = 0; index < Items.Count; index++)
Items[index].Apply(subMenu, context, index, index);
}
else
{
subMenu.SetBindingMemberValue(AttachedMembers.Menu.ItemsSourceGenerator,
new MenuItemsSourceGenerator(subMenu, context, ItemTemplate ?? this));
XmlPropertySetter<object, object>.AddBinding(setter.BindingSet, subMenu, AttachedMemberConstants.ItemsSource, ItemsSource, true);
}
}
else
{
var menuItem = menu.Add(groupId, id, order, string.Empty);
setter = new XmlPropertySetter<MenuItemTemplate, IMenuItem>(menuItem, context, new BindingSet());
menuItem.SetBindingMemberValue(AttachedMembers.Object.Parent, menu);
SetDataContext(menuItem, setter.BindingSet, dataContext, useContext);
ApplySelf(menuItem, setter);
}
setter.Apply();
}
示例5: OnCreateOptionsMenu
public override bool OnCreateOptionsMenu(IMenu menu)
{
base.OnCreateOptionsMenu(menu);
int groupId = 0;
//Unique menu item identifier. used for event handling.
int menuItemId = Menu.First;
//The order position of the item
int menuItemOrder = Menu.None;
//Text to be displayed for this menu item
int menuItemText = Resource.String.hello;
//Create the menu item and keep a referance to it
IMenuItem menuItem1 = menu.Add(
groupId,
menuItemId,
menuItemOrder,
menuItemText);
menuItem1.SetShortcut('1', 'a');
int MenuGroup = 10;
IMenuItem menuItem2 = menu.Add(
MenuGroup,
menuItemId + 10,
menuItemOrder + 1,
new Java.Lang.String("Menu Item 2"));
IMenuItem menuItem3 =
menu.Add(
MenuGroup,
menuItemId + 20,
menuItemOrder + 2,
new Java.Lang.String("Menu Item 3")
);
ISubMenu sub = menu.AddSubMenu(
0,
menuItemOrder + 30,
menuItemOrder + 3,
new Java.Lang.String("Submenu 1")
);
sub.SetHeaderIcon(Resource.Drawable.Icon);
sub.SetIcon(Resource.Drawable.Icon);
IMenuItem submenuItem = sub.Add(
0,
menuItemId + 40,
menuItemOrder + 4,
new Java.Lang.String("Submenu Item")
);
IMenuItem submenuItem2 =
sub.Add(
MenuGroup,
menuItemId + 50,
menuItemOrder + 5,
new Java.Lang.String("sub-1")).SetCheckable(true);
IMenuItem submenuItem3 =
sub.Add(
MenuGroup,
menuItemId + 60,
menuItemOrder + 6,
new Java.Lang.String("sub-2")).SetCheckable(true);
return true;
}