ListView/Adapter IllegalStateException

来源:互联网 发布:idea java log4j使用 编辑:程序博客网 时间:2024/05/21 03:17

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)

0 0