ListView/Adapter IllegalStateException
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.
是不是你在用 adapter.notifyDataSetChanged() 刷新listview的时候,如果当前listview还未来得及刷新,你就去触摸listview,就会导致跳出出错信息呢?
解决办法是,通过设置listview.setVisibility(View.VISIBLE/View.GONE)。
在 adapter.notifyDataSetChanged() 之前调用listview.setVisibility(View.GONE);在adapter.notifyDataSetChanged() 之后调用listview.setVisibility(View.VISIBLE)
本文解决了ListView在使用adapter.notifyDataSetChanged()刷新时出现IllegalStateException的问题。通过在调用adapter.notifyDataSetChanged()前后设置listview的可见性,避免了从后台线程修改adapter内容而导致的错误。
122

被折叠的 条评论
为什么被折叠?



