public void SetHomeAction(ActionBarAction action)
 {
     mHomeBtn.SetOnClickListener(this);
     mHomeBtn.Tag = action;
     mHomeBtn.SetImageResource(action.GetDrawable());
     mHomeLayout.Visibility = ViewStates.Visible;
     ((RelativeLayout.LayoutParams)mTitleLayout.LayoutParameters).AddRule(LayoutRules.RightOf, Resource.Id.actionbar_home_bg);
 }
 public void AddAction(ActionBarAction actionBarAction)
 {
     ActionList.Add(actionBarAction);
     m_StringIds.Add(actionBarAction.PopUpMessage == 0 ? "ERROR" : mContext.Resources.GetString(actionBarAction.PopUpMessage));
 }
        /// <summary>
        /// Inflates a View with the given Action.
        /// </summary>
        /// <param name="action">the action to inflate</param>
        /// <returns>a view</returns>
        private View InflateAction(ActionBarAction action)
        {
            var view = mInflater.Inflate(Resource.Layout.ActionBar_Item, mActionsView, false);

            var labelView =
                view.FindViewById<ImageButton>(Resource.Id.actionbar_item);
            labelView.SetImageResource(action.GetDrawable());

            view.Tag = action;
            view.SetOnClickListener(this);
            view.SetOnLongClickListener(this);
            return view;
        }
        private View InflateOverflowAction(ActionBarAction action)
        {
            var view = mInflater.Inflate(Resource.Layout.OverflowActionBar_Item, mActionsView, false);

            var labelView =
                view.FindViewById<ImageButton>(Resource.Id.actionbar_item);
            labelView.SetImageResource(action.GetDrawable());

            var spinner = view.FindViewById<Spinner>(Resource.Id.overflow_spinner);
            m_OverflowAction.OverflowSpinner = spinner;

            labelView.Tag = action;
            labelView.SetOnClickListener(this);
            //view.SetOnLongClickListener(this);

            m_OverflowAction.Activity = CurrentActivity;
            return view;
        }
        /// <summary>
        /// Adds a new Action at the specified index.
        /// </summary>
        /// <param name="action">the action to add</param>
        /// <param name="index">the position at which to add the action</param>
        public void AddAction(ActionBarAction action, int index)
        {
            var addActionBar = false;

            var hideAction = false;
            if (!ActionBarUtils.ActionFits(CurrentActivity, index + 1, m_HasMenuButton, action.ActionType))
            {
                if(!m_HasMenuButton)
                {
                    addActionBar = m_OverflowAction.ActionList.Count == 0;
                    m_OverflowAction.AddAction(action);
                    hideAction = true;
                }
            }
            else
            {
                if (m_OverflowAction.ActionList.Count != 0)//exists
                    index = m_OverflowAction.Index;//bring it inside

                hideAction = true;

                mActionsView.AddView(InflateAction(action), index);
            }

            //simply put it in the menu items to hide if we are a menu item.
            var taskAction = action as MenuItemActionBarAction;
            if (taskAction != null && hideAction)
                MenuItemsToHide.Add(taskAction.MenuItemId);

            if (addActionBar)
                AddOverflowAction(m_OverflowAction);
        }
        /// <summary>
        /// Remove a action from the action bar.
        /// </summary>
        /// <param name="action">The action to remove</param>
        public void RemoveAction(ActionBarAction action)
        {
            for (var i = 0; i < mActionsView.ChildCount; i++)
            {
                var view = mActionsView.GetChildAt(i);

                if (view == null) continue;

                var tag = view.Tag;
                var actionBarAction = tag as ActionBarAction;

                if (actionBarAction == null || !actionBarAction.Equals(action)) continue;

                var menuItemAction = tag as MenuItemActionBarAction;
                if (menuItemAction != null)
                    MenuItemsToHide.Remove(menuItemAction.MenuItemId);

                mActionsView.RemoveView(view);
            }
        }
 /// <summary>
 /// Adds a new Action.
 /// </summary>
 /// <param name="action">Action to add.</param>
 public void AddAction(ActionBarAction action) 
 {
     AddAction(action, mActionsView.ChildCount);
 }
 /// <summary>
 /// Adds new action in the overflow
 /// </summary>
 /// <param name="action">Action to add.</param>
 public void AddOverflowAction(ActionBarAction action)
 {
     var index = mActionsView.ChildCount;
     mActionsView.AddView(InflateOverflowAction(action), index);
     m_OverflowAction.Index = index;
 }
Esempio n. 9
0
        private View InflateOverflowAction(ActionBarAction action)
        {
            var view = _inflater.Inflate(Resource.Layout.OverflowActionBar_Item, _actionsView, false);


            var labelView =
                view.FindViewById<ImageButton>(Resource.Id.actionbar_item);


            if (null != ItemBackgroundDrawable)
            {
                labelView.SetBackgroundDrawable(ItemBackgroundDrawable.GetConstantState().NewDrawable());
            }
            else if (ItemBackgroundDrawableRaw > 0)
            {
                labelView.SetBackgroundResource(ItemBackgroundDrawableRaw);
            }

            labelView.SetImageResource(action.GetDrawable());

            var spinner = view.FindViewById<Spinner>(Resource.Id.overflow_spinner);
            _overflowAction.OverflowSpinner = spinner;

            labelView.Tag = action;
            labelView.SetOnClickListener(this);
            //view.SetOnLongClickListener(this);

            _overflowAction.Activity = CurrentActivity;
            return view;
        }
Esempio n. 10
0
        /// <summary>
        /// Inflates a View with the given Action.
        /// </summary>
        /// <param name="action">the action to inflate</param>
        /// <returns>a view</returns>
        private View InflateAction(ActionBarAction action)
        {
            var view = _inflater.Inflate(Resource.Layout.ActionBar_Item, _actionsView, false);

            if (null != ItemBackgroundDrawable)
            {
                view.SetBackgroundDrawable(ItemBackgroundDrawable.GetConstantState().NewDrawable());
            }
            else if (ItemBackgroundDrawableRaw > 0)
            {
                view.SetBackgroundResource(ItemBackgroundDrawableRaw);
            }

            var labelView =
                view.FindViewById<ImageButton>(Resource.Id.actionbar_item);
            labelView.SetImageResource(action.GetDrawable());

            view.Tag = action;
            view.SetOnClickListener(this);
            view.SetOnLongClickListener(this);

            if (action.PopUpMessage > 0)
                view.ContentDescription = Resources.GetString(action.PopUpMessage);

            return view;
        }
Esempio n. 11
0
        public void SetHomeAction(ActionBarAction action)
        {
            _homeBtn.SetOnClickListener(this);
            _homeBtn.Tag = action;
            _homeBtn.SetImageResource(action.GetDrawable());
            _homeLayout.Visibility = ViewStates.Visible;

            if (null != ItemBackgroundDrawable)
            {
                _homeBtn.SetBackgroundDrawable(ItemBackgroundDrawable.GetConstantState().NewDrawable());
            }
            else if (ItemBackgroundDrawableRaw > 0)
            {
                _homeBtn.SetBackgroundResource(ItemBackgroundDrawableRaw);
            }


            ((LayoutParams)_titleLayout.LayoutParameters).AddRule(LayoutRules.RightOf, Resource.Id.actionbar_home_bg);
        }
Esempio n. 12
0
 /// <summary>
 /// Adds a new Action at the specified index.
 /// </summary>
 /// <param name="action">the action to add</param>
 /// <param name="index">the position at which to add the action</param>
 public void AddAction(ActionBarAction action, int index)
 {
     var newAction = InflateAction(action);
     mActionsView.AddView(newAction, index);
 }
Esempio n. 13
0
        /// <summary>
        /// Inflates a View with the given Action.
        /// </summary>
        /// <param name="action">the action to inflate</param>
        /// <returns>a view</returns>
        private View InflateAction(ActionBarAction action)
        {
            var view = m_Inflater.Inflate(Resource.Layout.ActionBar_Item, m_ActionsView, false);

            if (null != ItemBackgroundDrawable)
            {
                view.SetBackgroundDrawable(ItemBackgroundDrawable.GetConstantState().NewDrawable());
            }

            var labelView =
                view.FindViewById<ImageButton>(Resource.Id.actionbar_item);
            labelView.SetImageResource(action.GetDrawable());

            view.Tag = action;
            view.SetOnClickListener(this);
            view.SetOnLongClickListener(this);
            return view;
        }