我的应用程序中有一个 TextView,其中每个单词都是可点击的跨度。一切正常,直到我长按任何单词,这会引发以下异常:
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.widget.Editor$SelectionModifierCursorController.getMinTouchOffset()' on a null object reference
at android.widget.Editor.touchPositionIsInSelection(Editor.java:917)
at android.widget.Editor.performLongClick(Editor.java:1018)
at android.widget.TextView.performLongClick(TextView.java:9436)
at android.view.View.performLongClick(View.java:5700)
at android.view.View$CheckForLongPress.run(View.java:22431)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6372)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
我尝试在 TextView 上设置 android:longClickable="false" 但徒劳无功。知道如何解决吗?
期待中的感谢!