本文整理汇总了C#中Android.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Android.Add方法的具体用法?C# Android.Add怎么用?C# Android.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android
的用法示例。
在下文中一共展示了Android.Add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreateOptionsMenu
// Menu aanmaken met de drie schermen voor navigatie binnen de applicatie
public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
{
base.OnCreateOptionsMenu(menu);
int groupId = 0;
int menuItemId = Android.Views.Menu.First;
int menuItemOrder = Android.Views.Menu.None;
// Text to be displayed for this menu item.
int menuItemText = Resource.String.menuitem1;
// Create the menu item and keep a reference to it.
//Het eerste menu item wordt hier toegevoegd
IMenuItem menuItem1 = menu.Add(groupId, menuItemId, menuItemOrder, menuItemText);
menuItem1.SetShortcut('1', 'a');
Int32 MenuGroup = 10;
//Het tweede menu item wordt hier toegevoegd
IMenuItem menuItem2 =
menu.Add(MenuGroup, menuItemId + 1, menuItemOrder + 1,
new Java.Lang.String("Toevoegen"));
menuItem2.SetShortcut('2', 'b');
//Het derde menu item wordt hier toegevoegd
IMenuItem menuItem3 =
menu.Add(MenuGroup, menuItemId + 2, menuItemOrder + 2,
new Java.Lang.String("Overzicht"));
menuItem3.SetShortcut('3', 'c');
return true;
}
示例2: CreateOptionsMenu
public static bool CreateOptionsMenu(this Context context, IParentMenu parentMenu, Android.Views.IMenu menu)
{
if (parentMenu == null)
{
return false;
}
#warning TODO - make this OO - let the _parentMenu render itself...
foreach (var child in parentMenu.Children)
{
var childCast = child as CaptionAndIconMenu;
if (childCast != null)
{
var item = menu.Add(1, childCast.UniqueId, 0, childCast.Caption);
if (!string.IsNullOrEmpty(childCast.Icon))
{
#warning TODO - cannot use Resourcein library code! Should we use reflection here? Or some other mechaniasm?
var resourceId = context.Resources.GetIdentifier(childCast.Icon, "drawable", context.PackageName);
if (resourceId > 0)
{
item.SetIcon(resourceId);
}
}
}
}
return true;
}
示例3: OnPrepareOptionsMenu
public override bool OnPrepareOptionsMenu (Android.Views.IMenu menu)
{
menu.Clear();
var items = _viewModel.OptionsMenu;
foreach(var item in items)
{
menu
.Add(0,
item.Id,
0,
new Java.Lang.String(item.Text));
var menuItem = menu.FindItem(item.Id);
switch(item.ShowAs)
{
case ShowAs.Hidden:
{
menuItem.SetShowAsAction(Android.Views.ShowAsAction.Never);
}
break;
case ShowAs.Visible:
{
menuItem.SetShowAsAction(Android.Views.ShowAsAction.IfRoom);
}
break;
default:
break;
}
}
return base.OnPrepareOptionsMenu(menu);
}
示例4: OnCreateOptionsMenu
public override void OnCreateOptionsMenu( Android.Views.IMenu menu, Android.Views.MenuInflater inflater )
{
// Fragment Menu Support: Call the base method
base.OnCreateOptionsMenu ( menu, inflater );
// Fragment Menu Support: Create menu item(s), as required, and add them to ActionBar option menu
IMenuItem item = menu.Add(0, 3, 0, "Frag Menu Item");
MenuCompat.SetShowAsAction(item, MenuItemCompat.ShowAsActionIfRoom);
}
示例5: OnCreateContextMenu
public override void OnCreateContextMenu(Android.Views.IContextMenu menu, View v,
Android.Views.IContextMenuContextMenuInfo menuInfo)
{
base.OnCreateContextMenu(menu, v, menuInfo);
Java.Lang.ICharSequence str0 = new Java.Lang.String("Context Menu");
Java.Lang.ICharSequence str1 = new Java.Lang.String("Item 1");
Java.Lang.ICharSequence str2 = new Java.Lang.String("Item 2");
Java.Lang.ICharSequence str3 = new Java.Lang.String("Item 3");
Java.Lang.ICharSequence strSubMenu = new Java.Lang.String("Submenu");
Java.Lang.ICharSequence strSubMenuItem = new Java.Lang.String("Submenu Item");
menu.SetHeaderTitle(str0);
menu.Add(0, Android.Views.Menu.First,
Android.Views.Menu.None, str1).SetIcon(Resource.Drawable.Icon);
menu.Add(0, Android.Views.Menu.First + 1, Android.Views.Menu.None, str2)
.SetCheckable(true);
menu.Add(0, Android.Views.Menu.First + 2, Android.Views.Menu.None, str3)
.SetShortcut('3', '3');
ISubMenu sub = menu.AddSubMenu(strSubMenu);
sub.Add(strSubMenuItem);
}
示例6: OnCreateOptionsMenu
public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
{
base.OnCreateOptionsMenu(menu);
int groupID = 0;
int menuItemID = Android.Views.Menu.First;
int menuItemOrder = Android.Views.Menu.None;
// Text weergegeven voor dit menu
int menuItemText = Resource.String.menuItem1;
// Maak het menu
// Item 1
IMenuItem menuItem1 = menu.Add(groupID, menuItemID, menuItemOrder, menuItemText);
Int32 MenuGroup = 10;
// Item 2
IMenuItem menuItem2 = menu.Add(MenuGroup, menuItemID + 1, menuItemOrder + 1, new Java.Lang.String("Formulier"));
// Item 3
IMenuItem menuItem3 = menu.Add(MenuGroup, menuItemID + 2, menuItemOrder + 2, new Java.Lang.String("Overzicht"));
return true;
}
示例7: OnCreateOptionsMenu
public override bool OnCreateOptionsMenu (Android.Views.IMenu menu)
{
// Menu items default to never show in the action bar. On most devices this means
// they will show in the standard options menu panel when the menu button is pressed.
// On xlarge-screen devices a "More" button will appear in the far right of the
// Action Bar that will display remaining items in a cascading menu.
menu.Add(new Java.Lang.String ("Normal item"));
var actionItem = menu.Add(new Java.Lang.String ("Action Button"));
// Items that show as actions should favor the "if room" setting, which will
// prevent too many buttons from crowding the bar. Extra items will show in the
// overflow area.
MenuItemCompat.SetShowAsAction(actionItem, MenuItemCompat.ShowAsActionIfRoom);
// Items that show as actions are strongly encouraged to use an icon.
// These icons are shown without a text description, and therefore should
// be sufficiently descriptive on their own.
actionItem.SetIcon(Android.Resource.Drawable.IcMenuShare);
return true;
}
示例8: OnTabSelected
public void OnTabSelected(ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
{
if (fragment == null)
{
fragment = new SampleTabFragment();
var id = (int)Build.VERSION.SdkInt >= 14 ?
Android.Resource.Id.Content :
Resource.Id.action_bar_activity_content;
ft.Add(id, fragment, "tag");
}
else
{
ft.Attach(fragment);
}
}
示例9: OnCreateOptionsMenu
public override void OnCreateOptionsMenu (Android.Views.IMenu menu, Android.Views.MenuInflater inflater)
{
MenuItemCompat.SetShowAsAction(menu.Add(new Java.Lang.String ("Menu 2")), (int)Android.Views.ShowAsAction.IfRoom);
}
示例10: OnTabSelected
public void OnTabSelected (Android.Support.V7.App.ActionBar.Tab tab, Android.Support.V4.App.FragmentTransaction ft)
{
ft.Add (Resource.Id.fragment_content, mFragment, mFragment.Text);
}