java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification
出现这个异常
listview 使用适配器进行数据刷新的时候出现的问题
主要原因是 list add 数据在子线程里面 注意必须在ui线程操作
解决方法 在 子线程 定义局部变量 list去add数据
然后通过handler 发送这个局部变量去更新数据
Message message = new Message();
message.what = YOURMSG;
message.obj = tempAppList;
mHandler.sendMessage(message);
然后在主线程中定义的mHandler中进行数据的绑定和更新,如下:
case YOURMSG:
//特别注意,在非UI线程下不能够对主线程中listview绑定的list数据进行修改。只能创建一个temlist,然后在
//handle里面赋值。
mAppsList = (ArrayList<AppInfo>) msg.obj;
mAppsAdp = new AppsListAdapter(mContext, mAppsList); //适配器
lv_list.setAdapter(mAppsAdp);//设置适配器
mAppsAdp.notifyDataSetChanged();