首页 > 通过线程与ui线程的交互来刷新adapter,总是遇到异常

通过线程与ui线程的交互来刷新adapter,总是遇到异常

线程不断检索list,然后通过handle向UI发出信息,更新adapter,然后就频繁地发生没有及时更新adapter的异常。
请问怎么解决?
异常信息: uncaughtException(): ex = 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. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131558445, class android.widget.ListView) with Adapter(class com.excelliance.kxqp.platforms.AddGameActivity$ListAdapter)]


请在UI线程调用notifyDataSetChanged()


在主线程中new Handler,然后用handler处理。或则调用activity的runOnUiThread方法处理


子线程做耗时操作,通过handler通知主线程notifydatachange

【热门文章】
【热门文章】