The content of the adapter has changed but ListView did not receive a notification
来源:互联网 发布:java开发erp系统 编辑:程序博客网 时间:2024/05/17 04:58
应用中有一个ListView
由于数据比较多,想用异步加载的方法。加载之前显示一个进度框,数据全部加载完毕之后再显示listview。
问题描述:
这个问题不经常出现,按返回键结束这个activity,然后再按主界面的按钮打开这个activity,就这样进进出出,四、五次的样子,就出错提示:The content of the adapter has changed but ListView did not receivea notification
问题程序:
Activity的 onCreate中
listview = (ListView) findViewById(R.id.listView1); listview.addFooterView(view_footer); lvAdapter = new ListViewAdapter(context); listview.setAdapter(lvAdapter); new ListTask(context).execute("");
异步类:
class ListTask extends AsyncTask<String,Integer,String>{ ProgressDialog pd; Context context; public ListTask(Context context){ this.context=context; pd=new ProgressDialog(context); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setCancelable(false); pd.setCanceledOnTouchOutside(false); } @Override protected String doInBackground(String... params) { m_prepareList(context); //读取数据库中的数据到lvAdapter的dataset中 return null; } @Override protected void onPreExecute(){ pd.show(); } @Override protected void onPostExecute(String result){ lvAdapter.notifyDataSetChanged(); pd.dismiss(); } }
解决方法:
最后试了好多方法都不能解决,看了网上的一篇文章:
http://blog.csdn.net/changemyself/article/details/8116670
说是数据更新后要及时notifyDataSetChanged();
后来想了一下,我的程序中的listview.setAdapter(lvAdapter);和lvAdapter.notifyDataSetChanged();毕竟隔了一个线程。所以试着把他们靠近点。
把listview.setAdapter(lvAdapter)放到onPostExecute中lvAdapter.notifyDataSetChanged()的上面,问题结解决。
- listview提示The content of the adapter has changed but ListView did not receive a notification
- ListView异常:The content of the adapter has changed but ListView did not receive a notification
- ListView The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification
- 解决bug:The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification
- .解决bug:The content of the adapter has changed but ListView did not receive a notification .
- The content of the adapter has changed but ListView did not receive a notification终极解决方法
- 处理The content of the adapter has changed but ListView did not receive a notification异常
- The content of the adapter has changed but ListView did not receive a notification错误分析
- The content of the adapter has changed but ListView did not receive a notification 异常解析
- 处理The content of the adapter has changed but ListView did not receive a notification异常
- The content of the adapter has changed but ListView did not receive a notification终极解决方法
- The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification.
- Linux下的source、export
- 不要试图和下属做朋友
- python as lambda fiter的使用
- java.util.jar.JarFile cause native heap memory leak
- poj 1012 约瑟夫
- The content of the adapter has changed but ListView did not receive a notification
- 用户sa登陆失败 microsoft sql server 错误18456
- UITableView cell自定义视图中插入UITableView
- 黑马程序员 交通灯管理系统的学习
- IntPtr与自定义结构互转
- Maven打包,并设置main方法启动
- 开通一个博客,还没有想好要写什么
- hdu1181 变形课(Floyd算法)
- 使用APC来 加密php代码