I've a custom Entry Renderer in Android and I've implemented BeforeTextChanged event so that I get the text which is gonna be entered, but it doesn't return that text.
I've implemented in two different ways:
First implementing ITextWatcher by the class and then overriding the mentioned event (helping this link):
void ITextWatcher.BeforeTextChanged(ICharSequence s, int start, int count, int after) { var test1 = new string(s?.ToArray()); var test2 = Control?.Text; SpannableString spannableString = new SpannableString(s); BackgroundColorSpan backgroundSpan = new BackgroundColorSpan(Color.Blue); spannableString.SetSpan(backgroundSpan, start, start + count, SpanTypes.ExclusiveExclusive); var test3 = spannableString; }
Second way:
Control.BeforeTextChanged += (sender, args) => { var test1 = new string(args?.Text.ToArray()); var entry = sender as EditText; var test2 = entry?.Text; var test3 = Control?.Text; };
But none of them will return the text that is about to be entered. What I want is to access that text and only in some circumstances allowing it to be inserted. I don't wanna use Behavior as it doesn't suit my need.