java.lang.IndexOutOfBoundsException: setSpan (N ... N) ends beyond length 10500

This is the actual method from android.text.SpannableStringBuilder where your code is failing.

private void checkRange(final String operation, int start, int end) {
    if (end < start) {
        throw new IndexOutOfBoundsException(operation + " " +
                region(start, end) + " has end before start");
    }

    int len = length();

    if (start > len || end > len) {
        throw new IndexOutOfBoundsException(operation + " " +
                region(start, end) + " ends beyond length " + len);
    }

    if (start < 0 || end < 0) {
        throw new IndexOutOfBoundsException(operation + " " +
                region(start, end) + " starts before 0");
    }
}

It looks like your start/end is greater than the length (calculated by length()) in the EditText. Probably a case of truncation.

As far as number of characters an EditText can hold is not restricted from Android OS, but probably from device. See Max 9000 characters in Android TextView? and also https://groups.google.com/forum/#!topic/android-developers/JVAm8vBaIQg


I had such a problem when using AutoCompleteTextView. The problem is that the auto-completion window opens with a delay. If during this delay you delete the text, then when you try to open the window, the popup tries to work with the already deleted text. The only way to avoid this is to cancel opening this window. This can be done by removing all operations from the Handler of this view. autoCompleteTextView.getHandler().removeCallbacksAndMessages(null);