所以我正在处理一个滚动布局,它有几个标题行(图片和诸如此类)和一个ViewPager。我正在使用MergeAdapter,因为我想使用Sticky List Headers库来制作ViewPager指示器选项卡,理想情况下,这些选项卡最终会成为技术上的列表项,在用户滚动时会粘在顶部。我正在做一切就像演示一样但是当我去运行我的代码时,我在logcat中得到了错误:
01-07 00:02:19.009: W/dalvikvm(12044): threadid=1: thread exiting with uncaught exception (group=0x40e2d930)
01-07 00:02:19.063: E/AndroidRuntime(12044): FATAL EXCEPTION: main
01-07 00:02:19.063: E/AndroidRuntime(12044): java.lang.RuntimeException: You must override newView()!
01-07 00:02:19.063: E/AndroidRuntime(12044): at com.commonsware.cwac.sacklist.SackOfViewsAdapter.newView(SackOfViewsAdapter.java:175)
01-07 00:02:19.063: E/AndroidRuntime(12044): at com.commonsware.cwac.sacklist.SackOfViewsAdapter.getView(SackOfViewsAdapter.java:147)
01-07 00:02:19.063: E/AndroidRuntime(12044): at com.commonsware.cwac.merge.MergeAdapter.getView(MergeAdapter.java:271)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.ListView.makeAndAddView(ListView.java:1831)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.ListView.fillDown(ListView.java:674)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.ListView.fillFromTop(ListView.java:735)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.ListView.layoutChildren(ListView.java:1652)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.AbsListView.onLayout(AbsListView.java:1994)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at com.slidingmenu.lib.CustomViewAbove.onLayout(CustomViewAbove.java:849)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:985)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.View.layout(View.java:14003)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewGroup.layout(ViewGroup.java:4375)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.Choreographer.doFrame(Choreographer.java:532)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)01-07 00:02:19.063: E/AndroidRuntime(12044): at android.os.Handler.handleCallback(Handler.java:725)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.os.Handler.dispatchMessage(Handler.java:92)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.os.Looper.loop(Looper.java:137)
01-07 00:02:19.063: E/AndroidRuntime(12044): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-07 00:02:19.063: E/AndroidRuntime(12044): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 00:02:19.063: E/AndroidRuntime(12044): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 00:02:19.063: E/AndroidRuntime(12044): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-07 00:02:19.063: E/AndroidRuntime(12044): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-07 00:02:19.063: E/AndroidRuntime(12044): at dalvik.system.NativeStart.main(Native Method)
我有MergeAdapter和SackOfViewsAdapter的jar文件,所以我无法弄清楚发生了什么。如果我注释掉ViewPager的内容,我甚至会得到同样的错误。
如果要通过addView,addViews等添加XML元素,是否有必要构建XML?
答案 0 :(得分:1)
不知何故,MergeAdapter
认为SackOfViewsAdapter
中的内容比实际内容更多,或者您在提交给{{1}的视图列表中有null
个条目}} MergeAdapter
(或您通过addViews()
添加的null
View
。我的资金在addView()
情景中。
您应该能够通过检查您作为null
的观点提供的内容来确定它是否是null
条目问题。
如果你无法追踪问题,并且你可以创建一个示例项目,那么使用指向样本源代码的指针重现错误file an issue,我将看一下它。