@Override
    public void setGravity(final int gravity) {
        try {
            super.setGravity(gravity);
        } catch (final IndexOutOfBoundsException ignored) {
            setText(getText().toString());
            super.setGravity(gravity);
        }
    }
Jelly beans can crash when calculating the layout of a textview.
<br>
<a href="https://code.google.com/p/android/issues/detail?id=35466">...</a>
main/src/main/java/cgeo/geocaching/ui/IndexOutOfBoundsAvoidingTextView.java