我在找到不断出现的nullpointerexeption时遇到了问题。 log cat没有显示“由...引起”标记,这就是很难找出实际问题的原因。如果有人能指导我找出问题所在,那就太棒了。我也试过运行调试器,我得到了提供的错误,但我不知道如何处理它。以下是我不断收到的错误消息,如果需要,我会发布代码。
调试器:
Thread [<1> main] (Suspended (exception NullPointerException))
<VM does not provide monitor information>
Choreographer.doCallbacks(int, long) line: 565
Choreographer.doFrame(long, int) line: 532
Choreographer$FrameDisplayEventReceiver.run() line: 735
Handler.handleCallback(Message) line: 725
Choreographer$FrameHandler(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 137
ActivityThread.main(String[]) line: 5329
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 511
ZygoteInit$MethodAndArgsCaller.run() line: 1102
ZygoteInit.main(String[]) line: 869
NativeStart.main(String[]) line: not available [native method]
Log Cat错误:
10-09 13:14:35.675: D/dalvikvm(12528): GC_CONCURRENT freed 825K, 9% free 35986K/39424K, paused 3ms+6ms, total 26ms
10-09 13:14:35.675: D/dalvikvm(12528): WAIT_FOR_CONCURRENT_GC blocked 2ms
10-09 13:14:35.705: I/endeffect(12528): AbsListView.onMeasure(), getWidth()=1080, getHeight()=1806, this=android.widget.ExpandableListView{43a168c0 VFED.VC. .F....ID 0,0-1080,1806 #7f060023 app:id/exp_list_view_deals_events}
10-09 13:14:35.705: D/AndroidRuntime(12528): Shutting down VM
10-09 13:14:35.705: W/dalvikvm(12528): threadid=1: thread exiting with uncaught exception (group=0x41467ac8)
10-09 13:14:35.716: E/AndroidRuntime(12528): FATAL EXCEPTION: main
10-09 13:14:35.716: E/AndroidRuntime(12528): java.lang.NullPointerException
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.AbsListView.obtainView(AbsListView.java:2615)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.ListView.measureHeightOfChildren(ListView.java:1253)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.ListView.onMeasure(ListView.java:1165)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
10-09 13:14:35.716: E/AndroidRuntime(12528): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2414)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.View.measure(View.java:16059)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2133)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1286)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1497)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1183)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4863)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.Choreographer.doFrame(Choreographer.java:532)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.os.Handler.handleCallback(Handler.java:725)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.os.Handler.dispatchMessage(Handler.java:92)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.os.Looper.loop(Looper.java:137)
10-09 13:14:35.716: E/AndroidRuntime(12528): at android.app.ActivityThread.main(ActivityThread.java:5329)
10-09 13:14:35.716: E/AndroidRuntime(12528): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 13:14:35.716: E/AndroidRuntime(12528): at java.lang.reflect.Method.invoke(Method.java:511)
10-09 13:14:35.716: E/AndroidRuntime(12528): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
10-09 13:14:35.716: E/AndroidRuntime(12528): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
10-09 13:14:35.716: E/AndroidRuntime(12528): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:1)
您在getView()
函数中返回null。
见这里: Crash in ListView at AbsListView.obtainView for ListActivity