TextView与clickablespan长按点击抛出异常

时间:2018-06-12 06:23:07

标签: android textview long-click

我的应用中有一个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)

我尝试过设置android:longClickable =" false"在TextView上却徒劳无功。知道如何解决这个问题吗?

满怀期待!

0 个答案:

没有答案