【问题标题】:Editor.java IndexOutOfBoundsException offset(x) should be less than line limit(y)Editor.java IndexOutOfBoundsException offset(x) 应该小于 line limit(y)
【发布时间】:2022-06-21 17:23:35
【问题描述】:

您好,有人知道这次崩溃吗?

仍然困惑如何重现。从 stackTrace 来看,它与 Email EditText 相关。

大部分发生在小米的 Redmi 设备和 100% Android 10

完整的堆栈跟踪

Editor.java line 3324
Fatal Exception: java.lang.IndexOutOfBoundsException
offset(18) should be less than line limit(17)

    android.text.TextLine.measure (TextLine.java:353)
    android.text.Layout.getHorizontal (Layout.java:1213)
    android.text.Layout.getHorizontal (Layout.java:1190)
    android.text.Layout.getPrimaryHorizontal (Layout.java:1160)
    android.text.Layout.getPrimaryHorizontal (Layout.java:1149)
    android.widget.Editor$ActionPinnedPopupWindow.computeLocalPosition (Editor.java:3324)
    android.widget.Editor$PinnedPopupWindow.show (Editor.java:3628)
    android.widget.Editor$ActionPinnedPopupWindow.show (Editor.java:3471)
    android.widget.Editor$EmailAddPopupWindow.show (Editor.java:4995)
    android.widget.Editor$1.run (Editor.java:1528)
    android.os.Handler.handleCallback (Handler.java:914)
    android.os.Handler.dispatchMessage (Handler.java:100)
    android.os.Looper.loop (Looper.java:225)
    android.app.ActivityThread.main (ActivityThread.java:7563)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:994)

【问题讨论】:

  • @micheal chen 你能找到任何解决方案吗?
  • 嗨@Shrikant,不幸的是,还没有
  • Shrikant @michael 你找到这个错误的原因了吗?
  • 还没有@Siklab.ph

标签: android android-edittext


【解决方案1】:
offset(X) should be less than line limit(Y)

我在 Android 12+ EditTexts 中遇到了类似的错误。出于某种原因,EditText.getText().length()(在上面的错误中称为 Y)与复制粘贴文本的实际长度(在以上错误)。

我们的解决方法是扩展EditText,然后手动调用setText("", TextView.BufferType.EDITABLE)(在我们的例子中,为onTextContextMenuItem),因为它似乎用实际文本长度更正了预期的文本长度。

【讨论】:

    猜你喜欢
    • 2011-04-24
    • 2011-09-29
    • 1970-01-01
    • 2017-12-02
    • 1970-01-01
    • 2011-03-20
    • 2012-12-07
    • 2012-10-26
    • 2011-07-27
    相关资源
    最近更新 更多