示例#1
0
        public override void OnBindViewHolder(Android.Support.V7.Preferences.PreferenceViewHolder holder)
        {
            base.OnBindViewHolder(holder);

            if (holder == null)
            {
                return;
            }

            var widgetFrame = holder.FindViewById(Android.Resource.Id.WidgetFrame);

            if (widgetFrame != null)
            {
                widgetFrame.Visibility = ViewStates.Visible;
            }

            var mintitle = (TextView)holder.FindViewById(Resource.Id.mintitle);

            if (mintitle != null)
            {
                mintitle.Text       = MinTitle ?? string.Empty;
                mintitle.Visibility = string.IsNullOrEmpty(MinTitle) ? ViewStates.Gone : ViewStates.Visible;
            }
            var maxtitle = (TextView)holder.FindViewById(Resource.Id.maxtitle);

            if (maxtitle != null)
            {
                maxtitle.Text       = MaxTitle ?? string.Empty;
                maxtitle.Visibility = string.IsNullOrEmpty(MinTitle) ? ViewStates.Gone : ViewStates.Visible;
            }

            SeekBar.Progress = Progress;

            var oldseekBar = holder.FindViewById(SeekBar.Id);

            if (oldseekBar != null && oldseekBar != SeekBar)
            {
                var container = (ViewGroup)oldseekBar.Parent;
                if (container != null)
                {
                    container.RemoveView(oldseekBar);
                    container.AddView(SeekBar, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                }
            }

            SubscribeEvents();
        }
示例#2
0
        public override void OnBindViewHolder(Android.Support.V7.Preferences.PreferenceViewHolder holder)
        {
            base.OnBindViewHolder(holder);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                return;
            }

            var titleView = (TextView)holder.FindViewById(Android.Resource.Id.Title);

            if (titleView == null)
            {
                return;
            }

            TypedArray typedArray = null;

            try
            {
                //http://stackoverflow.com/questions/27611173/how-to-get-accent-color-programmatically
                var colorAttrId = Context.Resources.GetIdentifier("colorAccent", "attr", Context.PackageName);
                if (colorAttrId <= 0)
                {
                    return;
                }

                typedArray = Context.ObtainStyledAttributes(new[] { colorAttrId });
                if (typedArray == null || typedArray.Length() <= 0)
                {
                    return;
                }

                var accentColor = typedArray.GetColor(0, 0xff4081); // defaults to pink
                titleView.SetTextColor(accentColor);
            }
            finally
            {
                typedArray?.Recycle();
            }
        }
示例#3
0
 public override void OnBindViewHolder(Android.Support.V7.Preferences.PreferenceViewHolder holder)
 {
     base.OnBindViewHolder(holder);
     ViewHolder = holder;
     BindViewHolder?.Invoke(this, EventArgs.Empty);
 }