public ActionBar(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            m_Context = context;
            mInflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);

            mBarView = (RelativeLayout)mInflater.Inflate(Resource.Layout.ActionBar, null);
            AddView(mBarView);

            mLogoView = mBarView.FindViewById<ImageView>(Resource.Id.actionbar_home_logo);
            mHomeLayout = mBarView.FindViewById<RelativeLayout>(Resource.Id.actionbar_home_bg);
            mHomeBtn = mBarView.FindViewById<ImageButton>(Resource.Id.actionbar_home_btn);
            mBackIndicator = mBarView.FindViewById(Resource.Id.actionbar_home_is_back);

            mTitleView = mBarView.FindViewById<TextView>(Resource.Id.actionbar_title);
            mActionsView = mBarView.FindViewById<LinearLayout>(Resource.Id.actionbar_actions);

            mProgress = mBarView.FindViewById<ProgressBar>(Resource.Id.actionbar_progress);
            mTitleLayout = mBarView.FindViewById<RelativeLayout>(Resource.Id.actionbar_title_layout);
            TypedArray a = context.ObtainStyledAttributes(attrs,
                    Resource.Styleable.ActionBar);

            m_OverflowAction = new OverflowActionBarAction(context);
            string title = a.GetString(Resource.Styleable.ActionBar_title);

            //check if pre-honeycomb. Ideally here you would actually want to check if a menu button exists.
            //however on all pre-honeycomb phones they basically did.
            var currentapiVersion = (int)Build.VERSION.SdkInt;
            m_HasMenuButton = currentapiVersion <= 10;

            if (title != null)
            {
                SetTitle(title);
            }
            a.Recycle();
        }
示例#2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (null != ItemBackgroundDrawable)
                    ItemBackgroundDrawable.Dispose();
                if (null != _inflater)
                    _inflater.Dispose();
                if (null != _overflowAction)
                    _overflowAction.Dispose();
                ItemBackgroundDrawable = null;
                _inflater = null;
                _barView = null;
                _logoView = null;
                _backIndicator = null;
                _titleView = null;
                _actionsView = null;
                _homeBtn = null;
                _homeLayout = null;
                _progress = null;
                _titleLayout = null;
                _context = null;
                _overflowAction = null;
            }

            base.Dispose(disposing);
        }
示例#3
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (null != ItemBackgroundDrawable)
                    ItemBackgroundDrawable.Dispose();
                if (null != m_Inflater)
                    m_Inflater.Dispose();
                if (null != m_OverflowAction)
                    m_OverflowAction.Dispose();
                ItemBackgroundDrawable = null;
                m_Inflater = null;
                m_BarView = null;
                m_LogoView = null;
                m_BackIndicator = null;
                m_TitleView = null;
                m_ActionsView = null;
                m_HomeBtn = null;
                m_HomeLayout = null;
                m_Progress = null;
                m_TitleLayout = null;
                m_Context = null;
                m_OverflowAction = null;
            }

            base.Dispose(disposing);
        }
示例#4
0
        public ActionBar(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            _context = context;
            _inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);

            _barView = (RelativeLayout)_inflater.Inflate(Resource.Layout.ActionBar, null);
            AddView(_barView);

            _logoView = _barView.FindViewById<ImageView>(Resource.Id.actionbar_home_logo);
            _homeLayout = _barView.FindViewById<RelativeLayout>(Resource.Id.actionbar_home_bg);
            _homeBtn = _barView.FindViewById<ImageButton>(Resource.Id.actionbar_home_btn);
            _backIndicator = _barView.FindViewById(Resource.Id.actionbar_home_is_back);

            _titleView = _barView.FindViewById<TextView>(Resource.Id.actionbar_title);
            _actionsView = _barView.FindViewById<LinearLayout>(Resource.Id.actionbar_actions);

            _progress = _barView.FindViewById<ProgressBar>(Resource.Id.actionbar_progress);
            _titleLayout = _barView.FindViewById<RelativeLayout>(Resource.Id.actionbar_title_layout);

            _overflowAction = new OverflowActionBarAction(context);

            //Custom Attributes (defined in Attrs.xml)
            var a = context.ObtainStyledAttributes(attrs,
                    Resource.Styleable.ActionBar);

            var title = a.GetString(Resource.Styleable.ActionBar_title);
            if (null != title)
                Title = title;

            var titleColor = a.GetColor(Resource.Styleable.ActionBar_title_color, Resources.GetColor(Resource.Color.actionbar_title));
            TitleColor = titleColor;

            var separatorColor = a.GetColor(Resource.Styleable.ActionBar_separator, Resources.GetColor(Resource.Color.actionbar_separator));
            _actionsView.SetBackgroundColor(separatorColor);

            using (var background = a.GetDrawable(Resource.Styleable.ActionBar_background)) //recycling the drawable immediately
            {
                if (null != background)
                    BackgroundDrawable = background;
            }

            var backgroundItem = a.GetDrawable(Resource.Styleable.ActionBar_background_item);
            if (null != backgroundItem)
                ItemBackgroundDrawable = backgroundItem;

            a.Recycle();
        }
示例#5
0
        public ActionBar(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            m_Context = context;
            m_Inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);

            m_BarView = (RelativeLayout)m_Inflater.Inflate(Resource.Layout.ActionBar, null);
            AddView(m_BarView);

            m_LogoView = m_BarView.FindViewById<ImageView>(Resource.Id.actionbar_home_logo);
            m_HomeLayout = m_BarView.FindViewById<RelativeLayout>(Resource.Id.actionbar_home_bg);
            m_HomeBtn = m_BarView.FindViewById<ImageButton>(Resource.Id.actionbar_home_btn);
            m_BackIndicator = m_BarView.FindViewById(Resource.Id.actionbar_home_is_back);

            m_TitleView = m_BarView.FindViewById<TextView>(Resource.Id.actionbar_title);
            m_ActionsView = m_BarView.FindViewById<LinearLayout>(Resource.Id.actionbar_actions);

            m_Progress = m_BarView.FindViewById<ProgressBar>(Resource.Id.actionbar_progress);
            m_TitleLayout = m_BarView.FindViewById<RelativeLayout>(Resource.Id.actionbar_title_layout);
            
            //check if pre-honeycomb. Ideally here you would actually want to check if a menu button exists.
            //however on all pre-honeycomb phones they basically did.
            var currentapiVersion = (int)Build.VERSION.SdkInt;
            m_HasMenuButton = currentapiVersion <= 10;

            m_OverflowAction = new OverflowActionBarAction(context);

            //Custom Attributes (defined in Attrs.xml)
            var a = context.ObtainStyledAttributes(attrs,
                    Resource.Styleable.ActionBar);

            var title = a.GetString(Resource.Styleable.ActionBar_title);
            if (null != title)
                Title = title;

            var titleColor = a.GetColor(Resource.Styleable.ActionBar_title_color, Resources.GetColor(Resource.Color.actionbar_title));
            TitleColor = titleColor;

            var separatorColor = a.GetColor(Resource.Styleable.ActionBar_separator, Resources.GetColor(Resource.Color.actionbar_separator));
            m_ActionsView.SetBackgroundColor(separatorColor);

            using (var background = a.GetDrawable(Resource.Styleable.ActionBar_background)) //recycling the drawable immediately
            {
                if (null != background)
                    BackgroundDrawable = background;
            }

            var backgroundItem = a.GetDrawable(Resource.Styleable.ActionBar_background_item);
            if (null != backgroundItem)
                ItemBackgroundDrawable = backgroundItem;

            a.Recycle();
        }