private void Rebind() { if (!enabled || DurationTextView == null) { return; } var durationShown = digitsEntered > 0 ? newDuration : oldDuration; var durationText = durationShown.ToString(); var durationSpannable = new SpannableString(durationText); durationSpannable.SetSpan( new ForegroundColorSpan(Color.LightGray), 0, durationSpannable.Length(), SpanTypes.InclusiveExclusive); if (digitsEntered > 0) { // Divider var sepIdx = durationText.IndexOf(":", StringComparison.Ordinal); if (sepIdx >= 0) { durationSpannable.SetSpan( new ForegroundColorSpan(Color.Black), sepIdx, sepIdx + 1, SpanTypes.InclusiveExclusive); } // Color entered minutes durationSpannable.SetSpan( new ForegroundColorSpan(Color.Black), durationText.Length - (Math.Min(digitsEntered, 2)), durationText.Length, SpanTypes.InclusiveExclusive); // Color entered hours if (digitsEntered > 2) { durationSpannable.SetSpan( new ForegroundColorSpan(Color.Black), 2 - (digitsEntered - 2), 2, SpanTypes.InclusiveExclusive); } } DurationTextView.SetText(durationSpannable, TextView.BufferType.Spannable); int num = 0; foreach (var numButton in numButtons) { numButton.Enabled = digitsEntered < 4; num += 1; } DeleteImageButton.Enabled = digitsEntered > 0; Add5Button.Enabled = newDuration.IsValid && newDuration.AddMinutes(5).IsValid; Add30Button.Enabled = newDuration.IsValid && newDuration.AddMinutes(30).IsValid; OkButton.Enabled = digitsEntered > 0 && newDuration.IsValid; }