Ejemplo n.º 1
0
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            var item1 = menu.Add(new Java.Lang.String("+"));

            //item1.SetIcon(Android.Resource.Mipmap.SymDefAppIcon);
            item1.SetShowAsAction(Android.Views.ShowAsAction.IfRoom);

            var item2 = menu.Add(new Java.Lang.String("-"));

            var item3 = menu.Add(new Java.Lang.String("Exit"));

            return(true);
        }
        public override void OnCreateOptionsMenu(Android.Views.IMenu menu, Android.Views.MenuInflater inflater)
        {
            var menuItem = menu.Add(0, MENU_CANCEL_SEARCH_ID, 0, new Java.Lang.String(""));

            menuItem.SetIcon(Resource.Drawable.abc_ic_clear_material);
            menuItem.SetShowAsAction(Android.Views.ShowAsAction.Always);
        }
Ejemplo n.º 3
0
        public override void OnCreateOptionsMenu(Android.Views.IMenu menu, Android.Views.MenuInflater inflater)
        {
            var config = Mvx.Resolve <IProductConfigService>().Config;

            if (ViewModel?.CartIndicatorVM != null)
            {
                var cartIndicatorType = config.Basket.CartIndicator.TypeName;

                var viewLookupService = Mvx.Resolve <IViewLookupService>();

                if (viewLookupService.IsRegistered(cartIndicatorType))
                {
                    if (Activator.CreateInstance(viewLookupService.Resolve(cartIndicatorType), Context) is IMvxAndroidView cartIndicatorView)
                    {
                        cartIndicatorView.BindingContext = new MvxAndroidBindingContext(Context, new MvxSimpleLayoutInflaterHolder(LayoutInflater), ViewModel.CartIndicatorVM);

                        var menuItem = menu.Add(0, MENU_CARD_INDICATOR_ID, 0, new Java.Lang.String(""));

                        menuItem.SetShowAsAction(Android.Views.ShowAsAction.Always);
                        menuItem.SetActionView(cartIndicatorView as Android.Views.View);
                    }
                }
            }

            if (ViewModel != null && ViewModel.SearchEnabled && !ViewModel.SearchBar && config.SearchType != SearchType.Disabled)
            {
                var menuItem = menu.Add(0, MENU_SEARCH_ID, 0, new Java.Lang.String(""));

                var typedValue = new TypedValue();
                Activity.Theme.ResolveAttribute(Resource.Attribute.app_products_ic_toolbar_search, typedValue, true);

                try
                {
                    var drawable = Activity.Resources.GetDrawable(typedValue.ResourceId, Activity.Theme);
                    menuItem.SetIcon(drawable);
                }
                catch
                {
                    MvxTrace.Trace(() => $"Not found drawable resource by id: {typedValue.ResourceId}");
                }

                menuItem.SetShowAsAction(Android.Views.ShowAsAction.Always);
            }
        }
        public override void OnCreateOptionsMenu(Android.Views.IMenu menu, Android.Views.MenuInflater inflater)
        {
            var menuItem = menu.Add(0, CLEAR_ID, 0, new Java.Lang.String(LocalizationService.GetLocalizableString(FiltersConstants.RESX_NAME, "Selection_Clear")));

            menuItem.SetShowAsAction(Android.Views.ShowAsAction.Always);
            menuItem.SetActionView(Resource.Layout.app_filters_filters_clearButton);
            menuItem.ActionView.Click += (sender, e) =>
            {
                ViewModel?.ClearCommand.Execute(null);
            };
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
 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);
 }