Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Editor$InsertionPointCursorController.show()' on a null object reference
at android.widget.Editor.performLongClick(Editor.java:1174)
at android.widget.TextView.performLongClick(TextView.java:12717)
at android.view.View.performLongClick(View.java:6954)
at android.view.View$CheckForLongPress.run(View.java:26066)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Method.java)
at
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
任何人都可以帮助我解决这次崩溃的问题。我是如何解决它的。
答案 0 :(得分:1)
某些设备在没有焦点时按住它们会引发我这个问题
在布局的每个可编辑组件中添加侦听器OnLongClick
textView.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
textView.requestFocus();
return false;
}
});