问题描述
我在CoordinatorLayout
的onTouchEvent
中得到了NullPointerException
.
我正在将DrawerLayout
与android支持AppCompat v23.0.0库的CollapsingToolbarLayout
一起使用.
I am using DrawerLayout
with CollapsingToolbarLayout
of android support AppCompat v23.0.0 library.
我观察到崩溃是在滚动CollapsingToolbarLayout
或单击抽屉项目时随机发生的.
My observation is crash happen randomly while scrolling CollapsingToolbarLayout
or click on drawer items.
有人遇到这个问题吗?有什么办法可以避免这种异常?
Is there anyone facing this issue? any work around to avoid this exception?
Logcat:
08-22 15:16:34.657: E/AndroidRuntime(27596): java.lang.NullPointerException: Attempt to invoke virtual method 'float android.view.MotionEvent.getX()' on a null object reference
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.View.onTouchEvent(View.java:9321)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.design.widget.CoordinatorLayout.onTouchEvent(CoordinatorLayout.java:449)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.View.dispatchTouchEvent(View.java:8388)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2398)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2158)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout.cancelChildViewTouch(DrawerLayout.java:1491)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout$ViewDragCallback.peekDrawer(DrawerLayout.java:1739)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout$ViewDragCallback.access$000(DrawerLayout.java:1624)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.support.v4.widget.DrawerLayout$ViewDragCallback$1.run(DrawerLayout.java:1630)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.os.Handler.handleCallback(Handler.java:739)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.os.Handler.dispatchMessage(Handler.java:95)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.os.Looper.loop(Looper.java:135)
08-22 15:16:34.657: E/AndroidRuntime(27596): at android.app.ActivityThread.main(ActivityThread.java:5221)
08-22 15:16:34.657: E/AndroidRuntime(27596): at java.lang.reflect.Method.invoke(Native Method)
08-22 15:16:34.657: E/AndroidRuntime(27596): at java.lang.reflect.Method.invoke(Method.java:372)
08-22 15:16:34.657: E/AndroidRuntime(27596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
08-22 15:16:34.657: E/AndroidRuntime(27596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
08-22 15:16:35.965: I/Process(27596): Sending signal. PID: 27596 SIG: 9
推荐答案
根据凯文·萨拉萨(Kevin Salazar)提出的链接,如果将支持库更新为版本23.0.1,该错误已修复.
According to the link posed by Kevin Salazar, the bug is fixed if you update your support library to version 23.0.1
这篇关于onTouchEvent中的CoordinatorLayout NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!