public void AfterTextChanged(IEditable s) { // Remove spacing char if (s.Length() > 0 && (s.Length() % 5) == 0) { char c = s.CharAt(s.Length() - 1); if (space == c) { s.Delete(s.Length() - 1, s.Length()); } } // Insert char where needed. if (s.Length() > 0 && (s.Length() % 5) == 0) { char c = s.CharAt(s.Length() - 1); // Only if its a digit where there should be a space we insert a space if (Character.IsDigit(c) && TextUtils.Split(s.ToString(), space.ToString()).Length <= 3) { s.Insert(s.Length() - 1, space.ToString()); } } }
private void Format(IEditable text) { if (text.Length() > 0) { for (int i = text.Length(); i > 0; i--) { if (!Character.IsDigit(text.CharAt(i - 1)) || ((deleting && i == start) && (isFormatChar(i)))) { text.Delete(i - 1, i); } } for (int i = 0; i < GetStringEnd(text); i++) { if (isFormatChar(i)) { text.Insert(i, Java.Lang.String.ValueOf(format[i])); } } } }