setSpan的IndexOutOfBoundsException - 在我的应用程序代码之外 [英] IndexOutOfBoundsException for setSpan - outside my application code

查看:1291
本文介绍了setSpan的IndexOutOfBoundsException - 在我的应用程序代码之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发布了对我的Android应用程序的更新,并获得了大量的崩溃报告,包含以下堆栈。我很茫然,因为堆栈中绝对没有我的代码,所以我不确定如何解决这个问题。有没有人见过这个错误?我可以做些什么来解决这个问题或调试它?

I recently published an update to my Android app and have been getting a ton of crash reports, with the following stack. I'm at a loss since there's absolutely no code of mine in the stack, so I'm not sure how to tackle this problem. Has anyone ever seen this error? Anything I can do to address this 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)

编辑:从堆栈看,它看起来像是通过ListView - > itemClick - >然后尝试用一个TextView中。我有多个可单击的listViews,其中包含textViews ...我可以在textViews上设置一个属性来阻止这种情况发生吗?

From the stack, it looks like it's going through a ListView -> itemClick -> then trying to do something with a TextView. I do have multiple clickable listViews with textViews in them... Is there a property I can set on the textViews to stop this from happening?

推荐答案

我认为你的字符串中有空格你有11个空白字符串但没有字符所以实际/修剪长度为零,这将导致错误设置选择。你可以在设置选择位置之前检查myString.trim()。lenght()> 0.

i think you have white spaces in your string you have like eleven white space string but no character so actual/trimmed length is zero, this will cause error to set selection. you can check myString.trim().lenght() > 0 before setting your selection position.

这篇关于setSpan的IndexOutOfBoundsException - 在我的应用程序代码之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆