예제 #1
0
        //add custom icon to tolbar
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            //MenuInflater.Inflate(Resource.Menu.action_menu, menu);

            //if (menu != null) {
            //             menu.FindItem(Resource.Id.action_barcode).SetVisible(true);
            //	menu.FindItem(Resource.Id.action_attach).SetVisible(false);

            //}
            //         IMenuItem actionMenuItem = menu.FindItem(Resource.Id.menuSearch);
            //         IMenuItem actionBarCode = menu.FindItem(Resource.Id.action_barcode);

            //         var barcode = menu.FindItem(Resource.Id.action_barcode);
            //         //var scanBarCode = barcode.ActionView.JavaCast<action>()

            //         var search = menu.FindItem(Resource.Id.menuSearch);
            //         var searchView = search.ActionView.JavaCast<Android.Support.V7.Widget.SearchView>();

            //         //searchView.QueryTextChange += (sender, e) => {
            //         //    Console.WriteLine(e.NewText);
            //         //};

            //return base.OnCreateOptionsMenu(menu);

            //MenuInflater.Inflate(Resource.Menu.main_menu, menu);
            //IMenuItem actionMenuItem = menu.FindItem(Resource.Id.menuSearch);

            //var search = menu.FindItem(Resource.Id.menuSearch);

            //var searchView = search.ActionView.JavaCast<Android.Support.V7.Widget.SearchView>();
            //return base.OnCreateOptionsMenu(menu);
            return(true);
        }
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            try
            {
                MenuInflater.Inflate(Resource.Menu.action_contactsListMenu, menu);
                if (menu != null)
                {
                    menu.FindItem(Resource.Id.action_menuOKOK).SetVisible(true);

                    var searchItems = menu.FindItem(Resource.Id.action_ContactSearch);

                    searchItems.SetVisible(true);

                    //MenuItemCompat.SetOnActionExpandListener(searchItems, new SearchViewExpandListener((IFilter)mAdapter));

                    var searchItem = MenuItemCompat.GetActionView(searchItems);
                    _searchView = searchItem.JavaCast <Android.Support.V7.Widget.SearchView>();
                    _searchView.SubmitButtonEnabled = true;

                    _searchView.QueryTextChange += (s, e) => mAdapter.Filter.InvokeFilter(e.NewText);
                }
            }
            catch (System.Exception ex)
            {
                Crashes.TrackError(ex);
            }
            return(base.OnCreateOptionsMenu(menu));
        }
예제 #3
0
 /// <summary>
 /// Inizializza pulsanti toolbar
 /// </summary>
 /// <param name="menu">Toolbar menu</param>
 public void Init(Android.Views.IMenu menu)
 {
     if (menu != null)
     {
         menu.FindItem(Resource.Id.action_refresh).SetVisible(true);
     }
 }
예제 #4
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            var editItem = menu.Add(0, EDIT_BTN_ID, 0, "Edit");

            editItem.SetShowAsAction(ShowAsAction.Always);
            return(base.OnCreateOptionsMenu(menu));
        }
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.main_screen, menu);

            _addAlarmMenuButton   = menu.FindItem(Resource.Id.add_alarm);
            _acceptMenuButton     = menu.FindItem(Resource.Id.accept);
            _alarmNameMenuItem    = menu.FindItem(Resource.Id.alarm_name);
            _deleteAlarmMenuItem  = menu.FindItem(Resource.Id.delete);
            _disableAlarmMenuItem = menu.FindItem(Resource.Id.switch_button);
            _alarmRadiusMenuItem  = menu.FindItem(Resource.Id.alarm_radius);
            _settingsMenuItem     = menu.FindItem(Resource.Id.action_settings);

            _alarmNameEditText      = MenuItemCompat.GetActionView(_alarmNameMenuItem) as EditText;
            _alarmNameEditText.Hint = Resources.GetString(Resource.String.alarm_name);
            _alarmNameEditText.SetWidth(Resources.GetDimensionPixelSize(Resource.Dimension.abc_search_view_preferred_width));

            _enableAlarmToggleButton = MenuItemCompat.GetActionView(_disableAlarmMenuItem) as ToggleButton;
            _enableAlarmToggleButton.CheckedChange += AlarmEnabledChange;

            _alarmRadiusSpinner = MenuItemCompat.GetActionView(_alarmRadiusMenuItem) as Spinner;
            var adapter = new ArrayAdapter(this, Resource.Layout.support_simple_spinner_dropdown_item,
                                           Android.Resource.Id.Text1, Constants.AlarmRadiusValues.Select(r => string.Format("{0} m", r)).ToList());

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            _alarmRadiusSpinner.Adapter       = adapter;
            _alarmRadiusSpinner.ItemSelected += (s, e) => RedrawAddCircle();

            ManageMenuItemsVisibilityForMode();

            _addAlarmMenuButton.SetVisible(_isGooglePlayServicesAvailable == ConnectionResult.Success);

            return(base.OnCreateOptionsMenu(menu));
        }
예제 #6
0
        public virtual void AddToParent(Android.Views.IMenu parent, int menuId, int index, bool showIfRoom)
        {
            var itemId = menuId * byte.MaxValue + index;

            ShowAsAction = showIfRoom ? ShowAsAction.IfRoom : ShowAsAction.Never;
            Item         = parent.Add(menuId, itemId, menuId, Title);
        }
예제 #7
0
        public override void OnCreateOptionsMenu(Android.Views.IMenu menu, MenuInflater inflater)
        {
            //MenuInflater.Inflate (Resource.Menu.Action_menu, menu);
            //menu.Clear();
            inflater.Inflate(Resource.Menu.Action_menu, menu);

            base.OnCreateOptionsMenu(menu, inflater);
        }
예제 #8
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            base.OnCreateOptionsMenu(menu);
            MenuInflater inflater = new MenuInflater(this);

            inflater.Inflate(Resource.Menu.activity_view_entry_menu, menu);
            return(true);
        }
예제 #9
0
 public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
 {
     if (WhiteLabelConfig.EXTERNAL_LINKS)
     {
         var actionItem1 = menu.Add(Resource.String.help);
         MenuItemCompat.SetShowAsAction(actionItem1, MenuItemCompat.ShowAsActionNever);
     }
     return(base.OnCreateOptionsMenu(menu));
 }
예제 #10
0
 //add custom icon to tolbar
 public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
 {
     MenuInflater.Inflate(Resource.Menu.action_menu, menu);
     if (menu != null)
     {
         menu.FindItem(Resource.Id.action_Addnew).SetVisible(true);
     }
     return(base.OnCreateOptionsMenu(menu));
 }
 public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
 {
     MenuInflater.Inflate(Resource.Menu.menu_main, menu);
     if (menu != null)
     {
         Menu = menu;
         menu.FindItem(Resource.Id.action_exit).SetTitle("Exit");
     }
     return(base.OnCreateOptionsMenu(menu));
 }
예제 #12
0
 public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
 {
     MenuInflater.Inflate(Resource.Menu.menu_registrar, menu);
     if (menu != null)
     {
         //menu.FindItem(Resource.Id.action_refresh).SetVisible(true);
         menu.FindItem(Resource.Id.action_editar).SetVisible(false);
     }
     return(base.OnCreateOptionsMenu(menu));
 }
예제 #13
0
 /// <summary>
 /// Creates the menu and inflates it
 /// </summary>
 /// <param name="menu">the menu created</param>
 /// <returns></returns>
 public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
 {
     MenuInflater.Inflate(Resource.Menu.menu, menu);
     for (int i = 0; i < menu.Size(); i++)
     {
         Android.Views.IMenuItem item = menu.GetItem(i);
         item.SetShowAsAction(Android.Views.ShowAsAction.Always);
     }
     return(base.OnCreateOptionsMenu(menu));
 }
예제 #14
0
        protected virtual async void SetupMenu(IMenu menu, int maxBottomItems, ShellItem shellItem)
        {
            menu.Clear();
            bool showMore = ShellItem.Items.Count > maxBottomItems;

            int end = showMore ? maxBottomItems - 1 : ShellItem.Items.Count;

            var currentIndex = shellItem.Items.IndexOf(ShellSection);

            List <IMenuItem> menuItems = new List <IMenuItem>();
            List <Task>      loadTasks = new List <Task>();

            for (int i = 0; i < end; i++)
            {
                var item = shellItem.Items[i];
                using (var title = new Java.Lang.String(item.Title))
                {
                    var menuItem = menu.Add(0, i, 0, title);
                    menuItems.Add(menuItem);
                    loadTasks.Add(SetMenuItemIcon(menuItem, item.Icon));
                    UpdateShellSectionEnabled(item, menuItem);
                    if (item == ShellSection)
                    {
                        menuItem.SetChecked(true);
                    }
                }
            }

            if (showMore)
            {
                var moreString = new Java.Lang.String("More");
                var menuItem   = menu.Add(0, MoreTabId, 0, moreString);
                moreString.Dispose();

                menuItem.SetIcon(Resource.Drawable.abc_ic_menu_overflow_material);
                if (currentIndex >= maxBottomItems - 1)
                {
                    menuItem.SetChecked(true);
                }
            }

            _bottomView.Visibility = end == 1 ? ViewStates.Gone : ViewStates.Visible;

            _bottomView.SetShiftMode(false, false);

            if (loadTasks.Count > 0)
            {
                await Task.WhenAll(loadTasks);
            }

            foreach (var menuItem in menuItems)
            {
                menuItem.Dispose();
            }
        }
예제 #15
0
        public override void OnCreateOptionsMenu(Android.Views.IMenu menu, Android.Views.MenuInflater inflater)
        {
            var typedValue = new TypedValue();

            Activity.Theme.ResolveAttribute(Resource.Attribute.app_map_ic_map, typedValue, true);

            var mapMenuItem = menu.Add(0, MENU_MAP_ID, 0, new Java.Lang.String(LocalizationService.GetLocalizableString(MapConstants.RESX_NAME, "Map_Title")));

            mapMenuItem.SetIcon(Resources.GetDrawable(typedValue.ResourceId, Context.Theme));
            mapMenuItem.SetShowAsAction(ShowAsAction.Always);
        }
예제 #16
0
 public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
 {
     MenuInflater.Inflate(Resource.Menu.action_menuOK, menu);
     if (menu != null)
     {
         menu.FindItem(Resource.Id.action_menuOKOK).SetVisible(true);
         //menu.FindItem(Resource.Id.action_ADDCONTACTS).SetVisible(false);
         //menu.FindItem(Resource.Id.action_SEARCH).SetVisible(false);
         //menu.FindItem(Resource.Id.action_CREATEGROUPS).SetVisible(false);
     }
     return(base.OnCreateOptionsMenu(menu));
 }
예제 #17
0
        public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
        {
            if (menu == null)
            {
                return;
            }
            menu.Clear();

            if (Menu.ButtonCount > 1 && Build.VERSION.SdkInt <= BuildVersionCodes.JellyBean)
            {
                var itemId = (int)OutputPane * byte.MaxValue;
                var item   = menu.Add((int)OutputPane, itemId, (int)OutputPane, Device.Resources.GetString("Menu"));
                item.SetShowAsAction(ShowAsAction.Always);
                const string source = "ic_menu_dark.png";
                ImageGetter.SetDrawable(source, (bitmap, url) =>
                {
                    if (url == source)
                    {
                        item.SetIcon(bitmap);
                    }
                });
            }
            else if (_buttons != null && _buttons.Length > 0 && _buttons[0]?.Item != null)
            {
                foreach (var button in _buttons)
                {
                    button.Item = menu.Add((int)OutputPane, button.Item.ItemId, (int)OutputPane, button.Title);
                }
            }
            else
            {
                var showIfRoom = true;
                _buttons = Enumerable.Range(0, Menu.ButtonCount).Select(i =>
                {
                    var menuItem = Menu.GetButton(i);
                    if (menuItem is UI.IMenu)
                    {
                        showIfRoom = false;
                    }
                    return(menuItem as MenuButton ?? menuItem?.Pair as MenuButton);
                }).ToArray();
                var subCount = 0;
                for (int i = 0; i < _buttons.Length; i++)
                {
                    var button = _buttons[i];
                    var menuId = button is IMenu ? subCount++ : (int)OutputPane;
                    button.AddToParent(menu, menuId, i, showIfRoom);
                }
            }
            base.OnCreateOptionsMenu(menu, inflater);
        }
예제 #18
0
        protected virtual void SetupMenu(IMenu menu, int maxBottomItems, ShellItem shellItem)
        {
            var currentIndex = ((IShellItemController)ShellItem).GetItems().IndexOf(ShellSection);
            var items        = CreateTabList(shellItem);

            BottomNavigationViewUtils.SetupMenu(
                menu,
                maxBottomItems,
                items,
                currentIndex,
                _bottomView,
                ShellItem.FindMauiContext());

            UpdateTabBarVisibility();
        }
예제 #19
0
        protected virtual void SetupMenu(IMenu menu, int maxBottomItems, ShellItem shellItem)
        {
            var currentIndex = shellItem.Items.IndexOf(ShellSection);
            var items        = CreateTabList(shellItem);

            BottomNavigationViewUtils.SetupMenu(
                menu,
                maxBottomItems,
                items,
                currentIndex,
                _bottomView,
                Context);

            UpdateTabBarVisibility();
        }
예제 #20
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.action_menuSearch, menu);
            if (menu != null)
            {
                menu.FindItem(Resource.Id.action_menuSearchSearch).SetVisible(true);
                var item = menu.FindItem(Resource.Id.action_menuSearchSearch);
                MenuItemCompat.SetOnActionExpandListener(item, new SearchViewExpandListener(_adapter));

                var searchItem = MenuItemCompat.GetActionView(item);
                _searchView = searchItem.JavaCast <Android.Support.V7.Widget.SearchView>();
                _searchView.QueryTextChange += (sender, e) => _adapter.Filter.InvokeFilter(e.NewText);
            }
            return(base.OnCreateOptionsMenu(menu));
        }
예제 #21
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.alarm_screen, menu);

            _deleteAlarmMenuItem  = menu.FindItem(Resource.Id.delete);
            _disableAlarmMenuItem = menu.FindItem(Resource.Id.switch_button);

            _enableAlarmToggleButton = MenuItemCompat.GetActionView(_disableAlarmMenuItem) as ToggleButton;
            _enableAlarmToggleButton.SetBackgroundResource(Resource.Drawable.toggle_button);
            _enableAlarmToggleButton.Checked        = _selectedAlarm.Enabled;
            _enableAlarmToggleButton.CheckedChange += AlarmEnabledChange;

            CorrectOptionsMenuVisibility();

            return(base.OnCreateOptionsMenu(menu));
        }
예제 #22
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            this.MenuInflater.Inflate(Resource.Menu.main_menu, menu);

            /*toolbar.MenuItemClick += (object sender, Android.Support.V7.Widget.Toolbar.MenuItemClickEventArgs e) =>
             * {
             *
             * };*/
            var searchItem = menu.FindItem(Resource.Id.action_search).ActionView;
            //var test = MenuItemCompat.GetActionView(searchItem);
            SearchManager searchmanager = (SearchManager)GetSystemService(SearchService);

            /*  var searchview = searchItem.JavaCast<Android.Widget.SearchView>();
             *
             * searchview.SetSearchableInfo(searchmanager.GetSearchableInfo(this.ComponentName));
             * searchview.SetIconifiedByDefault(true);*/
            return(true);
        }
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            ISubMenu langMenu = menu.AddSubMenu(Menu_Language.ToCharSequence());

            foreach (KeyValuePair <string, string> language in languageDict)
            {
                langMenu.Add(language.Key.ToCharSequence());
            }

            ISubMenu styleMenu = menu.AddSubMenu(Menu_Style.ToCharSequence());

            foreach (KeyValuePair <string, string> style in styleDict)
            {
                styleMenu.Add(style.Key.ToCharSequence());
            }

            return(true);
        }
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.action_bookListMenu, menu);
            if (menu != null)
            {
                var searchItems = menu.FindItem(Resource.Id.action_BookSearch);

                searchItems.SetVisible(true);

                //MenuItemCompat.SetOnActionExpandListener(searchItems, new SearchViewExpandListener((IFilter)mAdapter));

                var searchItem = MenuItemCompat.GetActionView(searchItems);
                _searchView = searchItem.JavaCast <Android.Support.V7.Widget.SearchView>();
                _searchView.SubmitButtonEnabled = true;

                _searchView.QueryTextChange += (s, e) =>
                {
                    if (String.IsNullOrEmpty(e.NewText))
                    {
                        paginationModel.SearchText = null;
                        LoadServerBooks();
                        // mAdapter.Filter.InvokeFilter(e.NewText);
                    }
                };

                _searchView.QueryTextSubmit += (s, e) =>
                {
                    LoadServerBooks(e.Query);
                };

                _searchView.Close += (s, e) =>
                {
                    paginationModel.SearchText = null;
                    LoadServerBooks();
                };


                MenuItemCompat.SetOnActionExpandListener(searchItems, new SearchViewExpandListener(mAdapter));
            }
            return(base.OnCreateOptionsMenu(menu));
        }
예제 #25
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            if (WhiteLabelConfig.EXTERNAL_LINKS)
            {
                var actionItem1 = menu.Add(Resource.String.help);
                MenuItemCompat.SetShowAsAction(actionItem1, MenuItemCompat.ShowAsActionNever);
            }


            if (WhiteLabelConfig.OFFLINE_CACHE)
            {
                var actionItem2 = menu.Add(0, 88, 0, Resource.String.cache);
                MenuItemCompat.SetShowAsAction(actionItem2, MenuItemCompat.ShowAsActionNever);

#if DEBUG
                var actionItem3 = menu.Add(0, 99, 0, "Fix Missing");
                MenuItemCompat.SetShowAsAction(actionItem3, MenuItemCompat.ShowAsActionNever);
#endif
            }

            return(true);
        }
예제 #26
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate(Resource.Layout.event_search_view, menu);

            IMenuItem searchItem = menu.FindItem(Resource.Id.action_search);
            var       mm         = MenuItemCompat.GetActionView(searchItem);
            var       searchView = mm.JavaCast <SearchView>();

            //SearchView searchView = mm as SearchView;
            searchView.QueryRefinementEnabled = false;
            searchView.QueryTextChange       += SearchView_QueryTextChange;
            searchView.QueryTextSubmit       += SearchView_QueryTextSubmit;
            searchView.Close += SearchView_Close;

            if (!WhiteLabelConfig.EXTERNAL_LINKS)
            {
                IMenuItem helpitem = menu.FindItem(Resource.Id.action_help);
                helpitem.SetVisible(false);
            }

            return(base.OnCreateOptionsMenu(menu));
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            int group = 0;

            IMenuItem item1 = menu.Add(group, SWAP_MENU, SWAP_MENU, "Swap Language");

            item1.SetIcon(Resource.Drawable.swap);
            item1.SetShowAsAction(ShowAsAction.Never | ShowAsAction.WithText);

            IMenuItem item2 = menu.Add(group, PINYIN_MENU, PINYIN_MENU, "Pinyin Toggle");

            item2.SetIcon(Resource.Drawable.pinyin);
            item2.SetShowAsAction(ShowAsAction.IfRoom);

            //IMenuItem item3 = menu.Add(group, SYNC_MENU, SYNC_MENU, "Sync");
            //item3.SetShowAsAction(ShowAsAction.Never | ShowAsAction.WithText);

            IMenuItem item4 = menu.Add(group, SETTINGS_MENU, SETTINGS_MENU, "Settings");

            item4.SetShowAsAction(ShowAsAction.Never | ShowAsAction.WithText);

            return(base.OnCreateOptionsMenu(menu));
        }
예제 #28
0
        protected virtual void SetupMenu(IMenu menu, int maxBottomItems, ShellItem shellItem)
        {
            if (DisplayedPage == null)
            {
                return;
            }

            if (ShellItemController.ShowTabs)
            {
                _menuSetup = true;
                var currentIndex = ((IShellItemController)ShellItem).GetItems().IndexOf(ShellSection);
                var items        = CreateTabList(shellItem);

                BottomNavigationViewUtils.SetupMenu(
                    menu,
                    maxBottomItems,
                    items,
                    currentIndex,
                    _bottomView,
                    MauiContext);
            }

            UpdateTabBarVisibility();
        }
        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);
        }
예제 #30
0
 public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
 {
     MenuInflater.Inflate(Resource.Menu.MainMenu, menu);
     return(base.OnCreateOptionsMenu(menu));
 }