定位 ArrayAdapter 创建的问题

Problems with locating ArrayAdapter creation

这是我目前得到的 Logcat 的结果:

E/AndroidRuntime( 8814): java.lang.NullPointerException
E/AndroidRuntime( 8814):    at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
E/AndroidRuntime( 8814):    at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
E/AndroidRuntime( 8814):    at android.widget.AbsListView.obtainView(AbsListView.java:2255)
E/AndroidRuntime( 8814):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
E/AndroidRuntime( 8814):    at android.widget.ListView.onMeasure(ListView.java:1175)
E/AndroidRuntime( 8814):    at android.view.View.measure(View.java:16521)
E/AndroidRuntime( 8814):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
E/AndroidRuntime( 8814):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
E/AndroidRuntime( 8814):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
E/AndroidRuntime( 8814):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
E/AndroidRuntime( 8814):    at android.view.View.measure(View.java:16521)
E/AndroidRuntime( 8814):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
E/AndroidRuntime( 8814):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
E/AndroidRuntime( 8814):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
E/AndroidRuntime( 8814):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
E/AndroidRuntime( 8814):    at android.view.View.measure(View.java:16521)
E/AndroidRuntime( 8814):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
E/AndroidRuntime( 8814):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime( 8814):    at android.view.View.measure(View.java:16521)
E/AndroidRuntime( 8814):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
E/AndroidRuntime( 8814):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime( 8814):    at android.view.View.measure(View.java:16521)
E/AndroidRuntime( 8814):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
E/AndroidRuntime( 8814):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime( 8814):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2552)
E/AndroidRuntime( 8814):    at android.view.View.measure(View.java:16521)
E/AndroidRuntime( 8814):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1915)
E/AndroidRuntime( 8814):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1084)
E/AndroidRuntime( 8814):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
E/AndroidRuntime( 8814):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
E/AndroidRuntime( 8814):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5603)
E/AndroidRuntime( 8814):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
E/AndroidRuntime( 8814):    at android.view.Choreographer.doCallbacks(Choreographer.java:574)
E/AndroidRuntime( 8814):    at android.view.Choreographer.doFrame(Choreographer.java:544)
E/AndroidRuntime( 8814):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
E/AndroidRuntime( 8814):    at android.os.Handler.handleCallback(Handler.java:733)
E/AndroidRuntime( 8814):    at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 8814):    at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 8814):    at android.app.ActivityThread.main(ActivityThread.java:5146)
E/AndroidRuntime( 8814):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 8814):    at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 8814):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
E/AndroidRuntime( 8814):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
E/AndroidRuntime( 8814):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  446):   Force finishing activity com.centervue.gsd/.activity.GsdMonitorActivity

有没有办法了解 ArrayAdapter 崩溃的原因?不幸的是,这个项目真的很大,是并发的,我不知道哪个崩溃了(调试器也帮不上什么忙):(

有什么想法吗?谢谢!

ArrayAdapter.java:394 中的资源为空。这是因为您尝试调用未指定的内容。

查看 ArrayAdapter 的来源,在我看来您没有指定正确的 textViewId 或错误的项目布局。如果您使用初始化适配器的代码更新您的问题,我可以更具体。

万一有人感兴趣,问题出在 DialogFragment 中,之前的编码器让 "null" 案例作为描述...所以进入 ArrayAdapter 的字符串数组就像“[null] " 导致崩溃。

将 null 的默认情况解析为更具描述性(而不是 null)的消息,解决了问题。