Android - ActionBar SearchView NullPointerException on Expand

时间:2014-02-20 21:59:34

标签: android nullpointerexception android-actionbar searchview drawerlayout

我一直在尝试在多个活动中实现SearchView,最终将根据输入过滤ListView适配器。该图标显示且可单击,但是当它展开时,它会崩溃应用程序,但会出现以下异常:

02-20 15:34:52.225: E/AndroidRuntime(24027): FATAL EXCEPTION: main
02-20 15:34:52.225: E/AndroidRuntime(24027): java.lang.NullPointerException
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.widget.ListView.fillSpecific(ListView.java:1342)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.widget.ListView.layoutChildren(ListView.java:1645)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.widget.AbsListView.onLayout(AbsListView.java:2447)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.View.layout(View.java:15204)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewGroup.layout(ViewGroup.java:4793)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:714)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.View.layout(View.java:15204)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewGroup.layout(ViewGroup.java:4793)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.View.layout(View.java:15204)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewGroup.layout(ViewGroup.java:4793)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:349)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.View.layout(View.java:15204)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewGroup.layout(ViewGroup.java:4793)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.View.layout(View.java:15204)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewGroup.layout(ViewGroup.java:4793)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2258)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2005)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1247)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6355)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.Choreographer.doCallbacks(Choreographer.java:591)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.Choreographer.doFrame(Choreographer.java:561)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.os.Handler.handleCallback(Handler.java:730)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.os.Handler.dispatchMessage(Handler.java:92)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.os.Looper.loop(Looper.java:137)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at android.app.ActivityThread.main(ActivityThread.java:5419)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at java.lang.reflect.Method.invokeNative(Native Method)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at java.lang.reflect.Method.invoke(Method.java:525)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
02-20 15:34:52.225: E/AndroidRuntime(24027):    at dalvik.system.NativeStart.main(Native Method)

我试过了:

  • 在支持和Android SearchView之间切换actionViewClass
  • 将DrawerLayout切换为LinearLayout
  • 默认视图打开 - 单击展开的视图时出现错误。

我已准备好尝试使用输入的编辑文本切换到自定义布局,而不是使用actionViewClass属性。

任何见解都表示赞赏。

0 个答案:

没有答案