IndexOutOfBoundsException for setSpan - outside my application code

I recently posted an update for my Android app and received a ton of crash reports with the following stack. I'm at a loss as there is no code on the stack, so I'm not sure how to solve this problem. Has anyone seen this error? Anything I can do to solve this problem or debug it?

java.lang.IndexOutOfBoundsException: setSpan (0 ... 11) ends beyond length 0 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1016) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:592) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:588) at android.widget.TextView.setSpan_internal(TextView.java:8610) at android.widget.Editor$SuggestionsPopupWindow.onItemClick(Editor.java:2902) at android.widget.AdapterView.performItemClick(AdapterView.java:298) at android.widget.AbsListView.performItemClick(AbsListView.java:1128) at android.widget.AbsListView$PerformClick.run(AbsListView.java:2812) at android.widget.AbsListView$1.run(AbsListView.java:3571) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5299) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(NativeStart.java) 

Edit: from the stack, it looks like it goes through ListView -> itemClick -> and then tries to do something using TextView. I have several clickable listViews with textViews in them ... Is there a property that I can set in textViews to prevent this from happening?

+6
source share
1 answer

I think that you have white spaces in your line, you have eleven lines of space, but not a single character, so the actual / cropped length is zero, this will cause an error to make a selection. you can check myString.trim (). lenght ()> 0 before setting the selection position.

+3
source

Source: https://habr.com/ru/post/978237/


All Articles