我编辑这张票。
我仍然看到那些在生产中发生的崩溃。很少,但我想了解问题所在。
我的跟踪中没有数据可以指示它在我的代码中崩溃的位置。
我应该在基于堆栈跟踪的代码中查找什么?
我搜索了java.lang.IllegalStateException android.widget.ListView.layoutChildren这个术语,我发现大多数注释都与notifyDataSetChanged相关,其中doc说:
通知附加的观察者基础数据已被更改,反映数据集的任何视图都应自行刷新。
我正在使用大约10个列表视图。我动态添加项目,它们永远不会改变。如果他们这样做,我清除列表并从头开始重建。
这是堆栈跟踪:
三星Galaxy S6(),3072MB RAM,Android 7.0 第1页,共6页
java.lang.IllegalStateException:
at android.widget.ListView.layoutChildren (ListView.java:1747)
at android.widget.AbsListView.onLayout (AbsListView.java:3008)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1079)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.RelativeLayout.onLayout (RelativeLayout.java:1079)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.support.v4.widget.DrawerLayout.onLayout (DrawerLayout.java:1197)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout (ActionBarOverlayLayout.java:433)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout (LinearLayout.java:1494)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout (DecorView.java:887)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2655)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2371)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1522)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7098)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:927)
at android.view.Choreographer.doCallbacks (Choreographer.java:702)
at android.view.Choreographer.doFrame (Choreographer.java:638)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:913)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6682)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
答案 0 :(得分:-1)
你需要调用函数
mListAdapter.notifyDataSetChanged();
在ListView中添加或删除之后
。