Недавно я начал использовать DrawerLayout в новом проекте около недели назад, и все это отлично работает. Помимо нечетных моментов, когда вы мотаете его пальцем, он падает.
Если я использую ActionBar Up/Home MenuItem, он будет работать каждый раз.
В LogCat я получаю две стека, которые, как кажется, указывают на внутренние места Android, поэтому я не совсем понимаю, что делать, чтобы решить эту проблему.
Я просто попытался создать новое приложение, чтобы узнать, было ли это что-то, что я делал до того, как это произошло, но это произошло и в новом приложении.
Я создал новое приложение с шаблоном Master/Detail Flow в окне "Новое приложение для Android", оставил все как по умолчанию и просто изменил файл activity_item_list.xml, чтобы он был внутри него:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_list"
android:name="com.navdrawertest.ItemListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context=".ItemListActivity"
tools:layout="@android:layout/list_content" />
<!-- Navigation Drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111" />
</android.support.v4.widget.DrawerLayout>
Отображается DrawerLayout, и я все еще могу перетащить его с края экрана, но он все равно сбой в этом тестовом приложении.
Вот те стеки, которые я вижу после перетаскивания пальцем:
07-26 09:29:45.574: E/InputEventReceiver(19085): Exception dispatching input event.
07-26 09:29:45.574: E/MessageQueue-JNI(19085): Exception in MessageQueue callback: handleReceiveCallback
07-26 09:29:45.584: E/MessageQueue-JNI(19085): java.lang.NullPointerException
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.support.v4.widget.DrawerLayout.isContentView(DrawerLayout.java:840)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.support.v4.widget.DrawerLayout.onInterceptTouchEvent(DrawerLayout.java:866)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1852)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.View.dispatchPointerEvent(View.java:7564)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.os.MessageQueue.nativePollOnce(Native Method)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.os.MessageQueue.next(MessageQueue.java:132)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.os.Looper.loop(Looper.java:124)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at android.app.ActivityThread.main(ActivityThread.java:5103)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at java.lang.reflect.Method.invokeNative(Native Method)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at java.lang.reflect.Method.invoke(Method.java:525)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-26 09:29:45.584: E/MessageQueue-JNI(19085): at dalvik.system.NativeStart.main(Native Method)
07-26 09:29:45.584: D/AndroidRuntime(19085): Shutting down VM
07-26 09:29:45.584: W/dalvikvm(19085): threadid=1: thread exiting with uncaught exception (group=0x41cbb700)
07-26 09:29:45.594: E/AndroidRuntime(19085): FATAL EXCEPTION: main
07-26 09:29:45.594: E/AndroidRuntime(19085): java.lang.NullPointerException
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.support.v4.widget.DrawerLayout.isContentView(DrawerLayout.java:840)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.support.v4.widget.DrawerLayout.onInterceptTouchEvent(DrawerLayout.java:866)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1852)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
07-26 09:29:45.594: E/AndroidRuntime(19085): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
07-26 09:29:45.594: E/AndroidRuntime(19085): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
07-26 09:29:45.594: E/AndroidRuntime(19085): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.View.dispatchPointerEvent(View.java:7564)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.os.MessageQueue.nativePollOnce(Native Method)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.os.MessageQueue.next(MessageQueue.java:132)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.os.Looper.loop(Looper.java:124)
07-26 09:29:45.594: E/AndroidRuntime(19085): at android.app.ActivityThread.main(ActivityThread.java:5103)
07-26 09:29:45.594: E/AndroidRuntime(19085): at java.lang.reflect.Method.invokeNative(Native Method)
07-26 09:29:45.594: E/AndroidRuntime(19085): at java.lang.reflect.Method.invoke(Method.java:525)
07-26 09:29:45.594: E/AndroidRuntime(19085): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-26 09:29:45.594: E/AndroidRuntime(19085): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-26 09:29:45.594: E/AndroidRuntime(19085): at dalvik.system.NativeStart.main(Native Method)
Я здесь что-то не хватает?
Изменить: 10 дней и все еще не могу понять это, могу ли я хотя бы получить подтверждение, что это не только я получаю это?